procmail
[Top] [All Lists]

Re: variables in conditions?

1996-06-03 11:42:14
Philip Guenther suggested to kevintx(_at_)ministry(_dot_)paranoia(_dot_)com:

| 2) the '$' to match end-o'-line I _believe_ also disappears (though maybe
|       not).  To be safe it should also be escaped.

No, it doesn't.  Escaping it is unnecessary unless there is text following it
on the condition line that could be coupled with it to look like a variable.
In that case, it was the last character in the expression, so there was no
such risk.  The $ modifier expands the expression as if it were on an sh
command line in weak quotes: "$" at the *end* of such a line would be taken
as a dollar sign (and thus as a newline in the regexp).  The same thing
applies if the character after the dollar sign is not legal in a Bourne shell
variable: procmail knows that it should not substitute anything.  There is,
though, an exception to the exception if you have a special variable, such
as $-, $=, or $$.  [$_ and ${number} are also special variables, but under-
scores and digits are not illegal in Bourne shell variable names.]

If ever you feel unsure, the construct

   ($)

always represents an end-of-line, and

   [$]

always represents a literal dollar sign, with or without the $ modifier.

I feel safer with those than with \$, which means a newline if the $ modifier
is present but a dollar sign without it.

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