procmail
[Top] [All Lists]

Re: procmail 'if' statements

2003-12-31 14:55:59
On Wed, Dec 31, 2003 at 02:47:40PM -0600, David W. Tamkin wrote:

 * $ -$LOWER_BOUND^0

    * $  -$SQLRESULT^0

Not a safe way to subtract a number.  If the number is negative, say, 
-3, procmail will expand that to

 --3^0

and read the caret as representing a newline in the middle of a text
string.

This is the best way I've found to subtract a number in a variable:

* $ $variable^-2 HOST ?? ^^.|.^^

It's a good trick, and a good rule for the general case.

In this specific case, I set $LOWER_BOUND to a known positive
number, so the danger isn't present.  Certainly, for adaptation
to other situations where the var can be negative or unknown,
then, absolutely . . .

Thanks, David.

-- 
dman

_______________________________________________
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>