procmail
[Top] [All Lists]

use of procmail's { } no-op

1998-07-12 10:51:21
Walter Dnes suggested this code to Dave Larson,

| :0
| * one-test-condition
| * another-test-condition
| * etc, etc
| { }
| VAR = $=

and gave these explanations.

|   You ask why the "{ }" (left-brace space right-brace).
|   1) If it's omitted, a negative score will be incorrectly
| reported as zero.

No, a negative score and a zero score will both be reported as null.

|   2) "{ }" is a nul-op, so the email is not considered to
| have been "delivered".  Without it, you would need the "f"
| flag, e.g. ":0f"

Walter must mean "c", not "f".  If a recipe's action would otherwise be
delivering, you can make it non-delivering by adding the "c" flag (procmail
will deliver a _c_opy instead).

The "f" flag (a filtering recipe) and VARIABLE=| action (a variable cap-
ture recipe) are by nature non-delivering, and so is "{" [as an action line
to open a brace nest].  "c" with "f" or with VARIABLE=| is redundant in
current versions of procmail; "c" with "{" will launch a clone.

Anyhow, an action line of "{ }" without "c" does nothing -- it opens a braced
block and then closes it.  It's good for setting up things for the recipes
that follow, such as saving a score or providing a reference point for the
"A" and "E" flags.  In fact, saving a score even if it is non-positive is
probably the second most common use of the no-op, the most common being this
way to OR conditions (we'll use three conditions in the example):

 :0 condition-related flags
 * ! condition1
 * ! condition2
 * ! condition3
 { } # no-op
 :0E action-related flags and local lockfile if needed
 action

That code will execute the action if the message meets condition1 or
condition2 or condition3.  (Of course, if the three conditions are regexp
searches over the same search area, they can be ORed more easily with pipe
symbols in a combined regexp.)

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