procmail
[Top] [All Lists]

Re: $ condition question

1999-10-18 02:47:36
"S.Toms" <tomas(_at_)primenet(_dot_)com> writes:
 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. For example what would be the difference between the
two

* $!^From:.*something
*  !^From:.*something

 In what instance(s) would you use the first, rather then the second.

When procmail goes to read a condition, if the line starts with a
dollarsign then procmail will perform bourne-shell style variable and
command (backquote) expansion on the rest of the line and reread the
result as a condition.  In the example you show above, procmail when
sees the dollarsign it performs variable and command expansions on

        !^From:.*something

The result of that expansion is

        !^From:.*something

So, in this case, the dollarsign did nothing.  However, let's say you
had an address stored in a variable ADDR and you wanted to see if the
message was from that address.  You can't just say:

        * ^From:.*$ADDR

because procmail will interpret that dollarsign as a regexp dollarsign
to be matched against the end of a line.  You have to tell procmail that
you want variables to be expanded:

        * $ ^From:.*$ADDR

If ADDR contained "guenther(_at_)gac(_dot_)edu", then the above condition would 
be
reread as

        ^From:(_dot_)*guenther(_at_)gac(_dot_)edu

I think this is described in most of the FAQ files for procmail availible
on the net.  You should probably scan through one or more of them as
there's all sorts of useful bits in them.  Here's a link to one such FAQ:

        http://www.iki.fi/~era/procmail/mini-faq.html


Philip Guenther

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