procmail
[Top] [All Lists]

Re: passing MATCH

1999-08-20 19:19:35
S.Toms asked,

| MAILLISTS=${PMDIR}/rc.mailinglists
| 
| :0h
| * ? test -f ${MAILLISTS} && (formail -zx TO_ | grep -i -f ${MAILLISTS})
| 
| can I use TO_ in that, or should I list all the headers to check?

List them all.  ^TO_ works in procmail regexp condition lines, not as an
argument to any formail options.

| Anyway,
| what I'm actually wondering is if I can catch the line in the $MAILLISTS
| for example, its checking address(_at_)mailinglist(_dot_)com if its 
successful how
| can I pass that particular address to the following

| {
|   :0
|   * MATCH ?? address(_at_)mailinglist(_dot_)com
|   {
|     # save to appropriate mailing-list folder
|     :0:
|     $MATCH
|   }
| }

The outer braces probably will ruin it, and the rest is just a bulky way of
saying

  :0:
  * MATCH ?? address(_at_)mailinglist(_dot_)com
  $MATCH

though you probably mean address(_at_)mailinglist\(_dot_)com ... anyhow, MATCH 
is set
only if you forcibly write

 MATCH=something

or if a condition line containing the \/ extraction operator is tried and the
expression matches (even if the condition is negated and thus, as a whole,
fails).  Otherwise it won't be set.

| I'm assuming it would be MATCH but when I checked, it was an empty
| variable.

You didn't do anything to assign a value to MATCH, nor to capture the output
of grep.

Probably you should use something like this, assuming your grep groks -f in
the first place:

 :0h
 * ? test -f $MAILINGLISTS
 LISTADDRESS=| formail -zx To: -x Cc: -x Resent-To: -x Resent-Cc: -x'From ' \
               -x Sender: -x Resent-Sender: | grep -if $MAILINGLISTS

  :0a: # note a, not A; previous condition must match AND previous action
       # must succed
  $LISTADDRESS

Of course it will still bomb if the header line with the list address
contains additional text.  What you really need is to find the line in
$MAILINGLISTS that appears within an address line in the headers.

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