procmail
[Top] [All Lists]

Re: recipe help: to me OR to ONE list (should be simple)

1996-10-14 15:28:11
  > However, I have not been able to succeed in addition the simple OR  
  > condition for one particular list I am on 'next-ftp' (actually it is  
  > next-ftp(_at_)peak(_dot_)org but it could be different things also, so I 
want  
  > to match the 'next-ftp' part)
  > 
  > I want any messages address to *luomat or *next-ftp to run the program.
  > 
  > * ^TO*luomat|*next-ftp
  >     didn't seem to work, nor did:
  > * ^TO*(luomat|next-ftp)
  > 
  > What is the proper way to do this with procmail 3.11?

Don't use "*" after ^TO.  And, you might consider using "^TO_", which is
part of 3.11 and uses a more stringent pattern.

In general, to do ORs with a common action in a procmail recipe, use
negated ANDS with an empty action, followed by an "else" action.  

From my college course in symbolic logic:

  p OR q  <=>  !( !p AND !q )

So, assuming two conditions, P and Q, and and an action 'A'.

  :0
  * P
  A

  :0 E
  * Q
  A

To represent this in a single recipe, do this:

  :0
  * !P
  * !Q
  {}

  :0 E
  A

Notice that the first recipe seems simpler, but doesn't scale as well
for multiple conditions, or complex actions.  For example, if there are
four conditions, P, Q, R, S, then the logic goes like this:

  :0
  * P
  A

  :0 E
  * Q
  A

  :0 E
  * R
  A

  :0 E
  * S
  A

If A is a nested block or a complex action, then this recipe is really
unwieldy, and the following pattern is better:

  :0
  * !P
  * !Q
  * !R
  * !S
  {}

  :0 E
  A

And, is much more concise.

___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks