On Fri, Jan 24, 2014 at 4:21 PM, Geoff Soper
<geoff(_dot_)procmail2401(_at_)alphaworks(_dot_)co(_dot_)uk> wrote:
Hi,
in various places within my procmail recipes I have the following string:
(^TO_|Delivered-To:)
How can I define this as a variable that I can use repeatedly in my recipes
and how do I include it in my recipes?
I'm not sure LuKreme actually answered your question ... his example
showed definitions of $NL and $WS for newline and whitespace but
didn't show any uses of them.
To define the pattern as a variable, you just use assignment syntax:
Delivered_TO = '(^TO_|Delivered-To:(.*[^-a-zA-Z0-9_.])?)'
(I've taken the liberty of fixing your pattern so that the scan of
Delivered-To: will behave like the rest of the headers examined by
^TO_)
Unlike the shell, procmail doesn't care about spaces around the "=",
use them or omit them as you please. Capitalization in the variable
name doesn't matter either, some people prefer all-caps to
differentiate variables from other strings in the pattern more
plainly.
To use it in a recipe, you probably need to use braces around the variable name:
:0
* ${Delivered_TO}geoff\.procmail2401
procmail-stuff
You could instead put parens around the pattern that follows:
:0
* $Delivered_TO(geoff\.procmail2401)
procmail-stuff
Either one will separate the "TO" from the "geoff", otherwise procmail
would try to look up "Delivered_TOgeoff" as the variable name and find
nothing.
As a last note, because $name is expanded as a variable reference, you
may sometimes have to use ($)name if you want to match a two-line
string that has "name" at the start of the second line.
____________________________________________________________
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