procmail
[Top] [All Lists]

Re: variables (for an exit code)

2002-10-09 20:51:18
Tom Allison asked,

| Is there some way that I can do something that looks like this:
|
| | /usr/bin/foo  #This is a filter that returns an exit code
| EXITCODE=$?
|
| And then, based on the exit code, either send the email to the
| default delivery point or to an alternate (like /dev/null).

First, as others (including Philip) have said, pick another name, one that
doesn't conflict with the special EXITCODE variable.  But here's what I
consider the cleanest way (note the space between the braces):

 :0HB
 * 1^1 ! ? /usr/bin/foo
 { }
 exitstatus = $=

If /usr/bin/foo needs to read only H or B or neither, modify the flags
accordingly.  I like it better than

 :0Wci
 | /usr/bin/foo

 exitstatus=$?

because (1) the effects of `W,' `c,' and `i' are automatic and one needn't
remember to include them, and (2) it clearly looks like a test and not like an
intended delivery.

But that's strictly a matter of personal preference; I don't readily see any
intrinsic advantage of either over the other.



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