procmail
[Top] [All Lists]

Re: Recipe syntax problem

1997-04-05 18:14:00
bodysurf(_at_)netcom(_dot_)com (Tim) writes:
...
Ok, now I make the following change to that section of the
"~/.procmailrc" file (adding the '0' to the lines marking the beginning
of a recipe -- lines 2 and 5 below) and all my emails get trashed:

      # Initialize FORMAIL variable:
      :0
      ? test -x /usr/local/nuglops/bin/formail
      { FORMAIL=/usr/local/nuglops/bin/formail }
      :0 E
      { FORMAIL=`ksh -c "echo ~vjl/bin/formail"` }


Okay folks, here are the rules used by procmail for identifying conditions:

0) If no number appears after the colon that starts the recipe, then
        examine the flags on the recipe.  If any of 'a', 'A', 'e', or
        'E' is given, then act as if a zero was present.  Otherwise act
        as if a one was present.

1) If there's a number greater than zero after the colon that starts
        the recipe, then that number of following lines are
        conditions.  A leading '*' will be ignored, but blank lines and
        lines that start with a '#' *will* be treated as conditions,
        and are not skipped.  Once those lines have been processed, act
        as if the number was zero and continue examining lines
        according to rule 2.

2) If the number is zero, then examine successive lines: if the line is
        blank or begins with a '#' then skip it; else if it begins with
        a '*' then it's a condition.  Otherwise it's the action.

Leading whitespace is skipped in all of these cases.  Trailing
backslashes will glue lines together except in comments.

The result of all of this is that the following tortured recipe has
five conditions, two lines skipped as comments, and one line skipped
as blank.

        :4
        ! a negated condition, not an action
        # not really a comment
        # \
        part of the previous line, which was a condition, not a comment

        # this is a comment, while that blank line was the final of the 4
        # the trailing backslash on this line does not affect the next line \
        * another condition, the next line will be skipped

        the-action

Of course, it is highly recommended that you *not* right recipes in
this style, but rather just start recipes with ":0" and prefix all your
conditions with '*'s.  Much clearer, simpler, and easier read than the
above.


Okay, now it should be obvious why the addition of the 0's changed the
behavior of procmail: with no numbers procmail treated the first recipe
as if it had a '1', while the second as if it had a zero.  You'll need
to prefix the condition on the first recipe with a '*' for it to
recognize the condition as such:

        # Initialize FORMAIL variable:
        :0
        * ? test -x /usr/local/nuglops/bin/formail
        { FORMAIL=/usr/local/nuglops/bin/formail }
        :0 E
        { FORMAIL=`ksh -c "echo ~vjl/bin/formail"` }


There, now you know all the dirty details, and everything should make sense,
right?

Philip Guenther

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