procmail
[Top] [All Lists]

Re: continue scoring in next recipe

2002-01-18 16:05:47
Sean wrote,

| Why not use the arithmetic expressions afforded to you by a good bourne
| type shell?

Because it involves invoking a shell for something that procmail can do
without help.

| so, in procmail, you could get the math result from:
|
| somescore=`echo $(( 12 + 3 ))`

That works only if /bin/echo is a shell script that hash-bangs a shell that
handles such expressions.  If /bin/echo is a binary, you'll probably just
get "$(( 12-3 ))" back.  Solution?  Force a shell:

 somescore=`echo $(( 12+3 ));`

But again, procmail can add integers internally, so the shell call is a
waste.

| * ? test $(( $myscore )) -gt $LIMIT

Again, if that's the only condition on the recipe, procmail needs no outside
help:

 * $ $myscore^0
 * $ -$LIMIT^0

Besides, even if you must do it that way,

 * ? test $myscore -gt $LIMIT

is just fine, or even

 * $ $((myscore>LIMIT))

where ">" will serve as the requisite visitor from $SHELLMETAS.

|          | formail -I "X-MyScore: $(( 1 * $myscore ))"

You're invoking a shell to multiple the number by one?  How, except for
burning cycles, is that going to give different results from

           | formail -I "X-MyScore: $myscore"

| If you don't have a Bourne-like shell supporting arithmetic operators,
| there is always 'bc', which requires piping the echo to resolve.

Again, if procmail can handle the arithmetic internally, calling bc (much
less a shell plus bc) to do it is just profligate.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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