procmail
[Top] [All Lists]

Re: Is there a option to OR the conditions instead of AND

1997-08-09 11:03:00
Alan Stebbens wrote,

| But, you can also use weighted scoring to form an OR condition.
| 
|     :0
|     * 1^0 ^From.*peter
|     * 1^0 ^From.*alex
|     * 1^0 ^From.*erwin
|     $BIGMAILBOX

Yes, you can; in fact, some times the requirements can't be combined into
a single condition and you have to use scoring or DeMorgan's Law to OR them.
There are a couple things I must point out, though.

First, particular to that example, the recipe might well need a local
lockfile.

Second, in general, if you use scoring to OR conditions, 1^0 is not a good
way to go.  The advantage to using DeMorgan's Law is that as soon as *any*
alternative is satisfied, procmail heads straight for the action.  The above
format with scoring takes the trouble to go on testing them all.

The way to use scoring but avoid that is like this: whenever a score reaches
supremum (+2147483647) procmail skips all remaining weighted conditions, con-
sidering the score to be irreversibly positive.  (It still tests any remain-
ing UNweighted conditions.)  [If the score reaches infemum (-2147483647),
procmail considers it irreversibly negative, deems the recipe a non-match,
and bails out for the next recipe; even if there are unweighted conditions
farther along, it skips them.]

Now, 2147483647 is hard to remember; Stephen's own trick is to use 9876543210
if you want to give the supremum weight to a single condition.  So you can do
this to OR conditions:

      :0:
      * 9876543210^0 ^From.*peter
      * 9876543210^0 ^From.*alex
      * 1^0 ^From.*erwin
      $BIGMAILBOX

(The last one can have any positive weight.)  This way procmail goes straight
to the action as soon as it finds a match to any condition.