[svlug] Dumb procmail question - recipies AND/OR
Aaron Lehmann
aaronl at vitelus.com
Wed Oct 4 20:37:01 PDT 2000
On Wed, Oct 04, 2000 at 01:43:53PM -0700, kmself at ix.netcom.com wrote:
> - Is there a shorthand way of specifying a number of sufficient
> conditions, any one of which should trigger an action (SVLUG seems
> particularly prone to misfiling, though other lists fall out as
> well).
http://www.ling.helsinki.fi/users/reriksso/procmail/mini-faq.html#oring
Q: How can I do a logical OR of two or more conditions?
(For those who skipped the manuals, the default is to AND all the
conditions on a recipe. The first one to fail makes Procmail skip
right to the next recipe.)
A: The usual reason people are asking this is because the following,
which is basically the way to do it, feels clumsy or something.
:0
* condition1|condition2|condition3|condition4
{ ... do something about it ... }
There are situations where you can't do this, such as when one of the
conditions is a negated condition. You can try to fool around with de
Morgan's laws to get you
somewhere where this doesn't play in, or use scoring:
:0
* 1^0 condition1|condition2
* 1^0 ! not condition 3
* 1^0 ? /path/to/external-program whose exit code we want to
* look at
{ ... now do something about that instead ... }
Some side effects are different when you resort to scoring; for
instance, if you are also using the \/ operator to grab stuff into
$MATCH, scoring will generally grab the last
matching line, whereas a straightforward regex OR will stop already at
the first one. (You can change the 1 in 1^0 to some really big number
to prevent this. See the
procmailsc(5) manual page if you wonder about the significance of
these strange numbers.)
More information about the svlug
mailing list