procmail
[Top] [All Lists]

Re: logical NOR

2002-11-19 09:03:43
Tom wrote,

| I'm trying to match an exitcode table like this:
|
| foo.sh    bar.sh    do { }
|     1         1        yes
|     0         1        yes
|     1         0        yes
|     0         0        no
|
| I know that this is a simple OR table.

So you want to do_something as long as either foo.sh or bar.sh reports failure
but nothing if both report success.  OK.

| But things like
|
| :0
| * ? (foo.sh || bar.sh)
| {  do something...  }

No, that won't do it.  That will do_something as long as foo.sh or bar.sh
reports success.  If both fail or both succeed, you won't get what you want.
Oddly,

 :0
 * ! ? foo.sh && bar.sh
 { do something }

would do the job correctly.  If foo.sh fails, the command string has a
non-zero exit code, so the condition (being negated) passes; if foo.sh
succeeds and bar.sh fails, same thing; if foo.sh and bar.sh both succeed, the
command string has a zero exit code, and negating the condition makes the
condition fail, so procmail skips the action.

| I did find this:
|
| :0
| *? foo.sh
| *? bar.sh
| {  }
| :0E
| {  do something... }
| Which does seem to work.

Yes, that will do it.  If foo.sh fails, or if foo.sh succeeds but bar.sh
fails, procmail will go to the `E'lse clause and do_something; if both
succeed, procmail will do what's in the first pair of braces (namely nothing).

| Now, here's where I keep getting really screwed up.
|
| When do I use
| :0
| * foo
| versus
| :0
| * ? foo

 * foo

looks for the pattern "foo" in the search area;

 * ? foo

checks the exit status of the command "foo."



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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