procmail
[Top] [All Lists]

Re: rewriting the subject line

2004-10-13 05:08:33
On Wed, Oct 13, 2004 at 01:26:43AM -0500, David W. Tamkin wrote:

Justin Gombos wrote:

* Dallman Ross <dman(_at_)nomotek(_dot_)com> [2004-10-09 10:35]:

:0 fw h
* TAG ?? .
* ^Subject:\/.*
| formail -I "Subject:$TAG$MATCH"

Shouldn't that be modded to reset the TAG variable, so it doesn't test
as positive on the next message?  ie..

 :0 fw h
 * TAG ?? .
 * ^Subject:\/.*
 {
 formail -I "Subject:$TAG$MATCH"
 TAG = ""
 }

I don't know the source of the snippet, so I can't comment on whether 
TAG should be cleared out or not, but if it should, that syntax will not 
invoke formail.  Try this:

 [snip]

Actually, it's probably harmless to unset TAG no matter what:

 :0fwh
 * TAG ?? .
 * ^Subject:\/.+
 | formail -I "Subject:$TAG$MATCH"

 TAG

Actually, I'm not at all that Justin should be wanting to clear the
var.  He should, though declare it unset (or null, as he wishes) up
at the top before the first test.


   TAG
   :0
   * some test for spam
   { TAG = " *** SPAM ***" }


   :0
   * ! TAG ?? .
   * some test for viruses
   { TAG = " *** VIRUS ***" }


   :0
   * ! TAG ?? .
   * some test for lists
   { TAG = " *** LIST ***" }


   :0 fw h
   * TAG ?? .
   * ^Subject:\/.*
   | formail -I "Subject:$TAG$MATCH"


and so on.


If for some reason his algorithm is different and he really does wish to
clear the var each time, then -- while David's syntax is just fine[1] --
my preference would be to unset it explicitly just before each place in
Justin's rc where he is attempting to set it.  That would be cleanest:
an explicit initialization to unset (or null) of the var is clear to
read when reviewing the code later.  One doesn't have to wonder if the
coder remembered or forgot about initialization, varname contamination
from previous statements not seen here (e.g., in prior rc's), etc.  So:


   TAG
   :0
   * some test for spam
   { TAG = " *** SPAM ***" }

   :0 fw h
   * TAG ?? .
   * ^Subject:\/.*
   | formail -I "Subject:$TAG$MATCH"



   TAG
   :0
   * some test for viruses
   { TAG = " *** VIRUS ***" }

   :0 fw h
   * TAG ?? .
   * ^Subject:\/.*
   | formail -I "Subject:$TAG$MATCH"


(Frankly, though, I find it a bit silly to repeat the formail recipe several
times like this.  And if one were going to, then at least grab the Subject
in one recipe up near the top, instead of each time.)


[1] The footnote about David's syntax has to do with his having changed my

   * ^Subject:\/.*

to

   * ^Subject:\/.+

Actually, each has a weakness in the anticipated application.  The
reason is that the message whose Subject is getting tagged might not
have had a Subject to start with.  If we require some text or char on a
Subject line after the header name "Subject:" in order to have a match
(David's syntax), or if we require a Subject line at all, though the
contents could be blank (my syntax), then we won't tag things we would
otherwise want to just because the sender didn't include text in the
Subject.

So it's better to have extracted the Subject up-top in the rc-file in any
case.

  MATCH
  :0
  * ^Subject:(.*\<)?\/.+
  { H_SUBJECT = "$MATCH" }


Then the formail recipe looks like this;

   :0 fw h
   * TAG ?? .
   | formail -I "Subject:$TAG $H_SUBJECT"


-- 
dman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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