procmail
[Top] [All Lists]

Re: Variable checking routine...

1997-12-02 06:39:38

I want to write a recipe which checks to see if a variable is set, and if
It isn't, sets it to a default value.  Will this recipe work?
:0:
* ! VARIABLE ?? .*
VARIABLE=defaultvalue

In short, no. ..... I
suspect that you meant

 :0
 * VARIABLE ?? ^^^^
 { VARIABLE=defaultvalue }

but that can be replaced by either of

 VARIABLE=${VARIABLE:-defaultvalue}

Just in case anyone missed a subtle detail, this replacement does not need
a procmail condition.  Since procmail will start over on the .procmailrc
for each message, the check and/or assignment will happen once per
message.  (I'm sure Rik knew this, but it wasn't obvious in the above.)

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