[linux-elitists] pr(awk|oc)mail must die

Seth David Schoen schoen@loyalty.org
Sun Oct 8 18:15:41 PDT 2000

Aaron Lehmann writes:

> As I was bashing my head into the wall trying to deal with awk, some
> kind soul pointed out MailDrop. apt-get it now. Imagine procmail with
> perl-like syntax and a level of power in between procmail and perl.
> For example, it actually has logical ors!!

Well, procmail has logical negation for conditions and for recipes (sort of,
with the "E" flag).  You can write a non-delivering recipe that tests for
the absence of the conditions you'd like to or; you can follow it with an
"E" recipe that does something.

The idea is

if ((!a) && (!b)){
} else {

and procmail has syntax that corresponds to each part of that code, so that
you can write recipes like that.

By DeMorgan's law you can see that the effect of that code is akin to

if (a || b) do_something_useful()

so there's your logical or.

It is easy to show that procmail rules are logically universal: any arbitrary
logic function of any arbitrary set of predicates can be expressed.  It might
not be elegant, though.  Because of procmail's block scope, you can actually
do this without assignments to any temporary variables.

I think the logical or would look like this:

* !^FROMdmarti@zgp.org
* !^FROMrick@linuxmafia.com

:0 E:

I haven't tried this, and I don't actually know procmail; I just read enough
of the documentation just now to try to show that you can do logical or using

To construct an arbitrary logic function is actually really easy -- hey,
even without nesting! -- using the E flag:

* !a
* !b
* !c

:0 E:
* !a
* !b
* c

:0 E:
* !a
* b
* !c

:0 E:
* !a
* b
* c

:0 E:
* a
* !b
* !c

# usw.

This can be made more concise by doing simplification with Karnaugh maps.

Obviously it would be nice to be able to write conditions directly instead of
doing logic synthesis.

I guess that I ought to test this to make sure it works, but I'm not going

Seth David Schoen <schoen@loyalty.org>  | And do not say, I will study when I
Temp.  http://www.loyalty.org/~schoen/  | have leisure; for perhaps you will
down:  http://www.loyalty.org/   (CAF)  | not have leisure.  -- Pirke Avot 2:5

More information about the linux-elitists mailing list