nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Ralph Corderoy
Subject: Re: [Nmh-workers] Multi-homed postproc, v2
Date: Thu, 05 Mar 2015 10:35:54 +0000

Hi Ken,

> 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.

This is Unix, not GNU and it's brain-damanged `rm / -rf'.  Isn't it a
bug that sendaux() appends ["-idanno", "42"] after the draft's filename?

> 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
    }

> 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?

Have the interface to post(8), and thus postproc, include the `file'
parameter as an environment variable as well.  True, this means post has
two places to get the data, but it also keeps simple filter scripts
simple.

Though I still think it should be the last argument, otherwise every
postproc author has to solve the same problem.

Cheers, Ralph.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]