procmail
[Top] [All Lists]

Re: $ condition question

1999-10-18 02:47:54
S.Toms sked,

|   Hey, I readthe man page a number of times, but I fail to totally
| understand exactly what the $ condition does. I figure it has something to
| do with the way it finds a match in the rule. But how it does this I
| havn't figured out.

If there is another dollar sign later in the condition and the next character
after it is legal in the name of a shell variable, or if there are backquotes
in the condition, then a $ modifier at the beginning says to treat the entire
expression as if it were encloded in soft quotations marks, replacing
anything beginning with a dollar sign (other than the initial one that turns
$ modification on) and a character legal in a shell variable with the value
of that variable, and running any command between backquotes and replacing it
with its standard output.

| For example what would be the difference between the two
| 
| * $!^From:.*something
| *  !^From:.*something

Absolutely nothing, because there are no dollar signs or backquotes later in
the line.

Here's an example where there is a difference:

  * ^TO_$LOGNAME(_at_)$HOST$

matches on anything that matches the expansion of ^TO_, plus a newline, plus
the seven letters "LOGNAME", plus an at-sign, another newline, plus the four
letters "HOST", and finally another newline.  But

  * $ ^TO_$LOGNAME(_at_)$HOST$

matches on anything that matches the expansion of ^TO_, plus the value of
the $LOGNAME variable, plus an at-sign, plus the value of $HOST, and finally
a newline.  The last dollar sign is treated as representing a newline because
it is not followed by a character that is legal in the name of a shell
variable.

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