Subject: Re: How to filter 'OR' conditions?

From: [email-masked] (David W. Tamkin)
Date: Tue, 28 Jun 1994 22:50:24 -0500 (CDT)

Bosco Tsang asked,

| Is it possible for me to check for 'OR' conditions in .procmailrc?

Yes, but that's not what you want to do in your particular situation.

| My currect .procmailrc will only check for To field as follows,
| 
| 	* ^To.*gis-l
| 	/userhome/btsang/gis/.
| 
| But some of the mail coming in are CC to that mailing list, not To that
| mailing list. How can I set it to check for gis-l both in To field and in
| Cc: field, so that if either one matches, it will save to directory gis?

Use procmail's built-in token ^TO (must be capitalized).  It matches on
To:.*, Cc:.*, and other variants of them.

For the general question of ORing conditions, however, there are four basic
solutions:

First, if the conditions are both expressions to egrep for, you can alter-
nate them with the pipe symbol like this ("^TO", in fact, employs this
method):

  * ^Subject: .*(sex|drugs)
or
  * (^TO|^From:.*)harry

Second, if they are both programs with exit codes to check, you can get the
shell to OR them:

  * ? program1 || program2

Third, you can use two recipes:

  :flags
  * condition1
  action

  :flags
  * condition2
  same_action

Fourth, if you're using a recent enough version that you have scoring, you
can do this:

  :flags
  * 2147483647^0 condition1
  * 1^0 condition2
  action

[2147483647 is the highest score procmail will tolerate; once a recipe
 reaches that score, procmail skips all remaining weighted conditions.
 If condition1 passes, you don't want to bother testing for condition2,
 so you give condition1 the maximum weight.  (Likewise, if the score on a
 recipe reaches -2147483648, the lowest possible score, procmail treats the
 conditions as not met and skips the rest of them, proceeding to the next
 recipe.)  On the other hand, if condition1 is not met and you must test for
 condition2, any positive score will do, and "1" is easy to type.]

David W. Tamkin  P. O. Box 3284  Skokie IL  60076-6284
[email-masked]   MCI Mail: 426-1818   +1 312 714 5610