procmail
[Top] [All Lists]

ORing

1997-11-26 20:39:58
Bob Poortinga wrote,

| OR is easy.

Not always, Bob.  You selected an example where it is, but not all ORing is
like your illustration:

| * (pattern1|pattern2)           # pattern1 OR pattern2

When the two tests to be ORed are a search of the same area for either of two
expressions (or any out of two or more) or a search of the same area for the
absence of both expressions (or all if there are two or more), yes, ORing is
easily done with a pipe symbol.  In fact, in Bob's example, the parentheses
are likely not even needed (but they don't hurt), depending on the particu-
lars of pattern1 and pattern2.

Likewise, two exit code tests can often be ORed like this:

  * ? command1 || command2

But there are many situations where two tests cannot be ORed by combining
them into one condition:

1. a regexp search of one area ORed with a regexp search of a different area
2. a positive regexp search [i.e., for a match to its pattern] ORed with a
   negative regexp search [i.e., for the absence of any match to its pattern]
3. an exit code condition ORed with a regexp search condition
4. an exit code condition seeking success ORed with an exit code condition
   seeking failure
5. a size test ORed with anything else (even another size test)

Bob's illustration may be enough for the ORing that Clint wants to do; per-
haps it is not.  We need to hear more of the specifics.

There are general ways to OR conditions that cannot be combined, but I won't
get into them here, as we have discussed them at great length several times
in the past.

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