% diagram 7

\verbatim
: 'mpick - relate messages /mtr'
PATH=:/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/lib/mh; export PATH
F="" M="" S=""

for A in $*
do
    case $A in
        -*)     S="$S $A" ;;

        +*|@*)  case $F in
                    "")  F=$A ;;
                    *)   echo "mpick: only one folder at a time" 1>&2
                         exit 1 ;;
                esac ;;

        *)      M="$M $A" ;;
    esac
done

S="$S -sequence hits -list -nozero"

if mark $F all -add -sequence hits;
    then mark $F all -delete -sequence hits;
    else exit 1;
fi

for A in ${M-cur}
do
    for C in `mhpath $F $A`
    do
        if [ -r $C ];
            then
                I=`mhl -form mhl.msgid $C`;
                case $I in
                    "")  echo "no message-id in message `basename $C`" 1>&2 ;;
                    *)   pick --in-reply-to "$I" $S ;;
                esac
            else
                echo "message $A doesn't exist" 1>&2; exit 1;
        fi
    done
done

exit 0
?endverbatim
