#! /bin/sh
# $Id: pick2me 1.2 1994/05/19 15:38:21 jerry Exp $
### pick2me - pick messages to me (in pick2me.addrs file or PICK2ME envariable)
### Usage: pick2me [pick switches like -sequence] [+folder] [msgs]
# 
#                             NO WARRANTY
# 
#   BECAUSE THIS PROGRAM IS AVAILABLE FREE OF CHARGE, THERE IS NO WARRANTY
# FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
# OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
# PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
# OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
# TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
# PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
# REPAIR OR CORRECTION.
# 
#   IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
# WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
# REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
# INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
# OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
# TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
# YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
# PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.


myname=`basename $0`

defaults=$myname.addrs  # default address file if $PICK2ME envariable not set
profargs=`mhparam $myname`  # options, if any, in MH profile

for addr in ${PICK2ME=`cat \`mhpath +\`/$defaults`}
do
    pickstr="-to '$addr' -or -cc '$addr' -or --resent-to '$addr' -or \
        --resent-cc '$addr'"
    case "$pickargs" in
    "") pickargs="$pickstr" ;;
    *)  pickargs="$pickargs -or $pickstr" ;;
    esac
done

# Use eval to interpret extra singlequotes in $pickstr.
# Add "-and -not -from $USER" to skip messages I sent and cc'ed to myself.
# The ${1+"$@"} trick works around problems with "$@" on some Bourne shells:
eval pick -lbrace $pickargs -rbrace -and -not -from $USER $profargs ${1+"$@"}
