procmail
[Top] [All Lists]

Re: capturing the OR that succeeds ???

2004-05-13 17:09:42
On Thu, May 13, 2004 at 11:47:42AM -0500, Michael D Schleif wrote:
Suppose that I have this:

   :0 BD
   * 9876543210^0 aaa
   * 9876543210^0 bbb
   * 9876543210^0 ccc
   * 9876543210^0 ddd
   * 9876543210^0 eee
   {
      :0 fhw
      | formail -I "X-Procmail: alphabet soup"
   
      :0 A
      alphabet/soup
   }

Yes, I am doing this several places, so I made this generic example;
but, it works as is.

However, now I want to identify _which_ condition was satisfied, and
plug that into the X-Procmail line:

   | formail -I "X-Procmail: alphabet soup: $MATCH"

I am confused, and I do not know the simplest way to do this capture?

Use the match token, '\/', before each regex.  Since you start the
matching at the start of the regex, you'll need to quote the match
token to avoid a syntax error.  Thus the empty parenthesis sets below:

     MATCH  # unset this first to avoid contamination from earlier recipes
     :0 BD
     * 9876543210^0 ()\/aaa
     * 9876543210^0 ()\/bbb
     * 9876543210^0 ()\/ccc
     * 9876543210^0 ()\/ddd
     * 9876543210^0 ()\/eee

However, you're still running body greps up to five times on "hit" messages
and all of five times on non-triggering messages.  You can have the same
effect with one pass like so:

  MATCH
  :0 D fw
  * B ?? ()\/(aaa|bbb|ccc|ddd|eee)
  | formail -I "X-Procmail: alphabet soup: $MATCH"

This has also avoided the unnecessary extra recipe you have above.

-- 
dman

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail