On Thu, 15 Mar 2001, era eriksson wrote:
Sorry for the massive delay in replying to this. I wanted to post the
solution for the archives. Era was correct in that I was not MATCHing
correctly. Basicly I already had the multiple Re Re Re problem solved, but
I was getting extra spaces in my Subject. I'm cross-posting to the
smartlist list as well, since this recipe is used in my rc.local.s20 file.
Background info follow the working recipe.
Here it is:
################################
#
:0 # is the subject tagged already? If not, capture it
* ! ^Subject:.*\[The\ Box\].*
* ^Subject: [ ]*\/[^ ].*$
{ # strip off any leading "Re: " strings
CURSUB=`echo $MATCH | sed -e 's/R[Ee]:[ ]*//'`
:0 fhw
| formail -I"Subject: [The Box] $CURSUB"
}
:0 Efhw # see if it is a tagged reply; if so, move the "Re:"
* ^Subject: *(Re: *)+\[The\ Box\] [ ]*\/[^ ].*$
| formail -I"Subject: [The Box] Re: `echo \"$MATCH\" | \
sed -e 's/^ *R[Ee]: *//g'`"
#
# NOTE: all above brackets contain <space> <tab>
#
###################################
The above recipe takes a subject and prepends [The Box] to it. Any
preceeding "Re:"s to [The Box] get moved: Subject: [The Box] Re: test.
Again, sorry for the late reply.
/vjl/
} On Wed, 14 Mar 2001 04:58:00 -0500 (EST), Dallman Ross
<dman(_at_)nomotek(_dot_)com>
} wrote:
} >> I'm having a problem with the follow recipe under procmail v3.10
}
} (That's an awfully old version, but I haven't been following this
} thread -- or the list -- so perhaps this has been noted alrady.)
}
} >> * ^Subject: *\/.*$
} > No need for the trailing `$', though it doesn't change anything
} > except perhaps the slowing of things down by a tiny, tiny
} > increment.
}
} Actually, it will include the trailing newline in MATCH, which may or
} may not be what you're after. But the " *" before the \/ doesn't skip
} any spaces. That's because the \/ operator changes how things are
} matched. You probably want "^Subject:[ ]*\/[^ ].*" with tabs and
} spaces in between the square brackets.
}
} $ cat <<'HERE' >~/scratch/r
} > SHELL=/bin/sh
} > :0
} > * ^Subject: *\/.*
} > { LOG="MATCH='$MATCH'
} > " }
} > :0
} > /dev/null
} > HERE
}
} $ while read subject; do
} > echo "Subject: $subject" | procmail ~/scratch/r
} > done <<'HERE'
} > subject
} > subject
} >
} > this is a test
} > HERE
} MATCH=' subject'
} MATCH=' subject'
} MATCH=' '
} MATCH=' this is a test'
}
} >> { # 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.
}
} I'd imagine the intent is to remove repeated Re: prefixes. The regular
} expression asks for space or beginning of line immediately before the
} R, which is not captured by your updated proposal.
}
} Try this instead:
}
} CURSUB=`echo "$MATCH" | sed -e 's/^\(R[Ee]:[ ]*\)*//'`
}
}
} It looks for and replaces repeated "Re: " prefixes at beginning of
} line (i.e beginning of the extracted, now hopefully canonicalized
} Subject).
}
} > 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.
}
} (No, that was not true with the earlier regex. See above.)
}
} > Btw, sed doesn't need an -e for just one expression - though it
} > doesn't hurt anything.
}
} (I use it routinely because it's easy to forget later if you make
} modifications to the sed script.)
}
} > 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. :-)
} ^^^^^^^^^^^^^^^^^^^^^^^^^
} Agree with this.
}
} I believe Eli the Bearded once posted a recipe which basically solved
} this even for pathological cases -- I'd go to the archives for a
} solution; this is by no means a new topic.
}
} Hope this helps,
}
} /* era */
}
}
--
Vince J. LaMonica // T e a m // Photographer: aviation, sports,
vjl(_at_)cullasaja(_dot_)com XX/ A M I G A // nature, art, travel, documentary
This e.mail was composed on Apr 6, 2001 at 3:53pm PDT.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail