procmail
[Top] [All Lists]

Re: problems with subject replacement recipe

2001-03-14 04:42:48
From: Vince LaMonica <vjl(_at_)cullasaja(_dot_)com>

I'm having a problem with the follow recipe under procmail v3.10
. . . .

:0    # is the subject tagged already?  If not, capture it
* ! ^Subject:.*\[PREFIX\].*

Hi, Vince.  Why would the subject be tagged already, I'm wondering, to
start?  You ought to set up one and only one place in your rc that
handles this prefixing that you want of subject.  But that's a minor
point.


* ^Subject: *\/.*$

No need for the trailing `$', though it doesn't change anything except
perhaps the slowing of things down by a tiny, tiny increment.

{    # strip off any leading "Re: " strings
  CURSUB=`echo $MATCH | sed -e 's/^ *R[Ee]: *//g'`

The above line is a problem.  You are telling sed to find multiple
instances of a line's beginning, for one; but there will only be one
match of a line's beginning.  So the g-flag is useless with the
leading caret.

Second, you've already stripped away leading spaces up above in your
original match of the subject.  So we don't need the ` *' after the
caret that we also didn't need.

Btw, sed doesn't need an -e for just one expression - though it
doesn't hurt anything.

Try just (untested, of course):

   CURSUB=`echo "$MATCH" | sed 's/R[Ee]: *//g'`

  :0 fhw
  | formail -I"Subject: [PREFIX] $CURSUB"
}
:0 Efhw    # see if it is a tagged reply; if so, move the "Re:"
* ^Subject: *(Re: *)+\[PREFIX\] *\/.*$
| formail -I"Subject: [PREFIX] Re: `echo \"$MATCH\" | sed -e 's/^ *R[Ee]: 
*//g'`"

My second cup of coffee has not helped me wake up enough to allow me to
have had light shed on what you're doing here exactly.  I see in general
terms, but don't follow your heuristic that requires munging the subject
both in the main recipe and in the "Else" (E-flag) recipe.  Maybe a
flow-chart on the back of a napkin would help - either you or me, or both
of us.  :-)  Basically, though, try to think through an algorithm that
only needs that mess once.  :-)  If I succeed at waking up some more
and think of something better, I'll let you know.

-- 
(For no weekly auto-reply, use dman+noacks(_at_)nomotek(_dot_)com)
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail