procmail
[Top] [All Lists]

Re: Exit code from an external program

2002-04-01 21:51:48
Here's another thought:

 :0
 * 1^1 ! ? progname
 { }
 returncode = $=

although, if one wants to distinguish positive failure codes from one
another, that really has no advantage over

 :0
 * ? progname
 { }
 returncode = $?

Philip recommended to Kevin,

:0 E
* $ -$?^0
| program died because of a signal

That didn't work when I tried it a few years ago.  If $? is negative, say,
for example, -2, the condition evaluated to

  * --2^0

which either (I don't remember) was a syntax error or searched for
<hyphen><hyphen>2<newline>0.  And when $? was positive or zero the scoring
syntax worked properly, but the score was non-positive, so the action was
never executed.

Here's a recipe that safely subtracts an integer variable (either positive
with no sign, negative with a leading hyphen, 0, or -0) from the score:

 * $ $var^-2 HOST ?? ^.|.$

While one might consider using other variables, I recommend HOST.  LOGNAME
might have only one character, and pretty much every other variable is
writable and thus could be null or could include a medial newline.  HOST is,
I'm quite sure, rock-solid.

It's less complicated if one wants just to test for a negative value,

 * var ?? ^-

or for a non-positive value,

 * var ?? ^^(-|0^^)



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