procmail
[Top] [All Lists]

Re: Removing [somelist] from subject lines

2001-01-21 06:54:07
Mike A. Harris wrote:
I've dabbled a bit in more complex [recipes], but not too deeply.  I
usually just ask for help to ensure no mail is lost.

Recently I dabbled too deep, and did lose a bunch.  ;o)

You could have something like

:0 c:
backup

at the beginning of your .procmailrc to save a copy of every incoming
message to a backup folder while you're testing something new, that
would ensure you don't lose anything for good even if there's
something wrong with your recipes.

I don't want the filter to see all messages, just
the ones from the group.  Here is an example header:

Date: Sat, 20 Jan 2001 18:12:49 +0100
From: Michael Vogt <mvogt(_at_)acm(_dot_)org>
To: xpert(_at_)XFree86(_dot_)Org
Content-Type: multipart/mixed; boundary="FCuugMFkClbJLl1L"
Subject: [Xpert]Memory Leak in XmuClientWindow() ?

My rule for this list goes something like:

:0:
* ^X-BeenThere:(_dot_)*xpert(_at_)XFree86(_dot_)Org
XPERT-XFREE

Um, I guess you just forgot to include the X-BeenThere header in the
example snippet? And if it's there, you probably can count on it to
have a fixed number of spaces/tabs after the colon, so you should be
able to use that instead of ".*".

I want to integrate the recipe you provide above into this rule,
so that the filter is only applied to this specific list.

Would the following be correct?

:0
* ^X-BeenThere:(_dot_)*xpert(_at_)XFree86(_dot_)Org
{
      :0hf
      * ^Subject:.*\[Xpert\]
      | sed 's/\[Xpert\] //'

      :0:
      XPERT-XFREE
}

That's fine - just a few details: (1) Do you really need to check the
subject line after you've already identified the message as coming
from the list? Don't all list messages have the "[Xpert]" added
anyway? (2) Your sed script removes "[Xpert] ", with a trailing space,
from the subject line; the lists I know all do have such a space after
the bracket, but it doesn't appear in your example header, so nothing
would happen there. (3) There's no need to put a "\" before the "]"
(though it doesn't do any harm either), neither in procmail's
condition nor in the sed script; only the "[" has to be escaped.
(4) You might consider adding a "w" flag to the first recipe in the
braces (:0 hfw). This way you have some kind of safety net: if sed
fails, e.g., because of a typo causing a syntax error in the script,
procmail will continue to process the original message instead of
sed's empty output, so you don't lose anything. In this case here the
danger is probably neglectible, but as soon as you start to have more
complicated filters, this can become useful pretty soon.

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