procmail
[Top] [All Lists]

Re: procmailrc script fine tuning

2006-04-26 04:09:46
On Tue, Apr 25, 2006 at 10:33:24PM -0500, David W. Tamkin wrote:

LDB wrote:

Does this,

e   This recipe only executes if the immediately preceding recipe
    failed

mean that the exit code was greater than 0? I hope it does for
my sake.

Yes, but it also requires that the immediately preceding recipe
on the same nesting level was attempted: passed its conditions
but failed its action.

Clarifying, "passed its conditions" will require specific
attention in procmail.  For example, this rcfile --

   :0
   | /usr/bin/false

   :0 e
   | /usr/bin/true


will NOT run the small-"e" else-recipe:

   12:38pm [~/Mail] 553[0]> procmail -m VERBOSE=y foo.rc < /dev/null
  procmail: [28027] Wed Apr 26 12:39:51 2006
  procmail: Assigning "MAILDIR=."
  procmail: Rcfile: "foo.rc"
  procmail: Assigning "LASTFOLDER=/usr/bin/false"
  procmail: Executing "/usr/bin/false"
    Folder: /usr/bin/false                                                      
1
  

I therefore would have answereed LDB's question not, immediately,
with a "yes," but with "only if you tell procmail to pay attention
to the exit code."

If we add a "w"-flag to the first recipe, it works as LDB
apparently expected it to:

   :0 w
   | /usr/bin/false
  
   :0 e
   | /usr/bin/true


   12:39pm [~/Mail] 556[1]> procmail -m VERBOSE=y foo.rc < /dev/null
  procmail: [21614] Wed Apr 26 12:38:45 2006
  procmail: Assigning "MAILDIR=."
  procmail: Rcfile: "foo.rc"
  procmail: Executing "/usr/bin/false"
  procmail: Program failure (1) of "/usr/bin/false"
  procmail: Assigning "LASTFOLDER=/usr/bin/false"
  procmail: Assigning "LASTFOLDER=/usr/bin/true"
  procmail: Executing "/usr/bin/true"
    Folder: /usr/bin/true                                                       
1
  

A "W" flag would behave the same way.  Only the "program failure" message
is suppressed then, but everything else is the same:

   12:42pm [~/Mail] 561[0]> procmail -m VERBOSE=y foo.rc < /dev/null
  procmail: [878] Wed Apr 26 12:42:28 2006
  procmail: Assigning "MAILDIR=."
  procmail: Rcfile: "foo.rc"
  procmail: Executing "/usr/bin/false"
  procmail: Non-zero exitcode (1) from "/usr/bin/false"
  procmail: Assigning "LASTFOLDER=/usr/bin/false"
  procmail: Assigning "LASTFOLDER=/usr/bin/true"
  procmail: Executing "/usr/bin/true"
    Folder: /usr/bin/true                                                       
1
  

Dallman's suggestion didn't use e; it used E, which means the
recipe is tried only if the immediately preceding recipe on the
same nesting level failed its conditions (and its action was not
run).

Yes, quite true and worth mentioning the distinction.  "e" runs
on a failed action (that is allowed to pass its exit code, e.g.,
with a "w" or "W" flag on that recipe).  That necessarily also
implies the passing recipe's *conditions* (if any) all succeeded,
however; else no action (that ultimately failed) would ever have
been attempted.  "E" requires no attempted action above, and,
indeed, implies there would not have been any, since failed
conditions alone are what triggers the subsequent recipe with
"E"-flag.

  -dman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail