procmail
[Top] [All Lists]

exactly once

2004-08-22 19:37:19
Hope this doesn't sound like bragging, but maybe this is one to file away.

On newsgroup comp.mail.misc -- except for Alan Clifford, I don't know who else here reads it -- someone asked how to test that the exit code of a program is exactly 1 ... not 0, not 2 or more. Besides straight-
forward but boring things like these:

 :0c
 | command

 RESULT=$?

 :0
 * RESULT ?? ^^1^^
 action

and

 :0
 * 1^1 ! ? command
 { }

 SCORE = $=

 :0
 * SCORE ?? ^^1^^
 action

I thought of this, and in testing, it worked for all values from 0 to 255, failing for 0 and for 2 through 255 but matching for 1:

 :0
 * 1^-.5 ! ? command
 * -.8^0
 action

It could be extended to testing whether a pattern appears exactly once:

 :0
 * 1^-.5 regexp
 * -.8^0
 action

Now if only that could be generalized to testing for numbers of occurrences (or for exit codes) other than 1.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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