nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] Multi-homed postproc, v2

2015-03-09 23:22:54
On Thu, 05 Mar 2015 10:35:54 +0000 Ralph Corderoy <ralph@inputplus.co.uk> sez:

find_draftmessage() {
        skip_next=0

        for arg; do
                case "$arg" in
                -al* | -filt* | -wi* | -client | -idanno | -server | \
                -partno | -saslmaxssf | -saslmech | -user | -por* | \
                -file* | -mhl* | -mt* | -cr* | -lib* | -oauth)
                        skip_next=1
                        ;;
                -*)     skip_next=0;
                        ;;
                *)
                        if [ "$skip_next" -eq 0 ]; then
                                draftmessage="$arg"
                                return 0
                        fi
                        skip_next=0
                        ;;
                esac
        done

    echo "Cannot find draft message name in argument list"
        exit 1
}

I think that can be simpler, given a function has a "$@" that's
distinct from the scripts, e.g.

    find_draftmessage() {
        while test $# -ne 0; do
            case "$1" in
            -al* | -filt* | -wi* | -client | -idanno | -server | \
            -partno | -saslmaxssf | -saslmech | -user | -por* | \
            -file* | -mhl* | -mt* | -cr* | -lib* | -oauth)
                shift
                ;;
            -*) ;;
            *)
                draftmessage="$1"
                return 0
                ;;
            esac
            shift
        done

        echo "usage: localpostproc [...] file [...]" >&2
        exit 1
    }

This works for me.  Thanks, Ralph!

Bob

_______________________________________________
Nmh-workers mailing list
Nmh-workers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>