nmh-workers
[Top] [All Lists]

[Nmh-workers] Multi-homed postproc, v2

2015-03-04 11:24:33
So after testing it for a day, I found a problem.  Specifically, if you're
using annotations on replies my simple script broke.  The reason is that the
arguments ended up being:

        [...] draft filename -idanno N

Where "N" was the file descriptor to write the annotation to; my previous
iteration assumed the last argument to post was the filename.

I ended up having to do this code (complete script appended at the end):

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 am just wondering out loud if there is a better way than putting knowledge
in the script of whether a particular switch takes an argument.  It just
seems brittle to me.  Ideas?  Other approaches?

--Ken

Attachment: localpostproc
Description: localpostproc

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers
<Prev in Thread] Current Thread [Next in Thread>