procmail
[Top] [All Lists]

Re: concatenating multiple $MATCHes?

2001-08-06 08:08:55
John Hardin asked,

| Is there any way to get $MATCH to return a concatenated list of all
| matched strings, instead of just the last one?

Actually, you'd normally get the first one; there is a way to get only the
last:

 * 1^1 reg\/exp

but that's a sidelight.

| For example (NOT real world) I'd like the following:
|
|   :0
|   * ^Received: \/.*
|   {
|      LOG="$MATCH"
|   }
|
| to return $MATCH containing all of the Received headers' text, not
| just the final one.
|
| Note that using Received: here is just to illustrate the problem. I
| want to do something completely different. It needs to pick multiple
| lines out of the message, and I'd like to avoid dropping to the shell
| and running (frex) sed if I can avoid it.

It can be done with a recursive INCLUDERC (or an INCLUDERC with a
self-recursive SWITCHRC call now that SWITCHRC exists), but that can be such
a pain to write properly and so clumsy to run that a calll to sed or grep is
certainly easier and possibly more efficient.  (If you literally wanted the
contents of all Received: headers, as you used for an example, I'd recommend
formail -zx Received:  rather than grep, sed, or a recursive subsidiary
rcfile.)

What you surely wouldn't need is a drop into a shell, but given that several
characters from $SHELLMETAS are also magic characters for sed or grep, you
might have to unset or reset SHELLMETAS temporarily to prevent procmail from
forking a superfluous shell.



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

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