David W. Tamkin wrote:
Dallman Ross wrote:
Fwiw, another approach for testing "just one" is to use the
"Infinity Shuffle":
Sorry, I don't see that. [. . . .] If we flip the logic,
INFINITY = 2147483647 # don't pad this one
:0
* 1^0
* -$INFINITY^0
* -1^-1 ! ? command
# Are we still here? Good: didn't happen more than once
* $ $INFINITY^0
{ }
:0E
action
then it will be right for all even values and for 1; if the command's
exit code is always 0, 1, or 2 and never 3 or higher, then it
will work.
But then it's just a hard way to write,
:0 # perform action if exit status is odd
* 1^-1 ! ? command
action
Your infinity shuffle is great for testing for a maximum or minimum
number of occurrences (or a maximum or minimum exit code from a ?
condition); this time we have a single desirable value surrounded by
undesirable ones.
I think you're right. Thanks for catching that. I've been
a bit ill, so I should be extra careful about proposing
something I haven't tested. Bronchitis / bacterial infections /
broad-spectrum antibiotics / etc.
Dallman
____________________________________________________________
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