procmail
[Top] [All Lists]

Re: Trimming the Subject

1998-01-14 09:24:38
On Wed, 14 Jan 1998 10:16:36 -0500, Vikas Agnihotri <VikasA(_at_)att(_dot_)com>
wrote:
Ideally, I dont want to fork off 'sed' to do the job and have procmail do
it itself?

This is hard, if not impossible. 

:0fh
{ 
 SUBJECT=|formail -x Subject|sed 's/-Reply//g'

 :0fh
 |formail -i "Subject: ${SUBJECT}"
}

You should have a :w flag, and make sure you only trim off -Reply:s at
the end of the string. I'd not even use formail, even if this is
slightly insecure (it will not work when the Subject spans more than
one physical line):

    :0fhw
    * ^Subject:.*-Reply[        ]*$
    | sed -e 's/^\(Subject:.*[^         ]\)\([   ]*-Reply[      ]*\)*$/\1/'

Some seds don't understand grouping parentheses, but I'd call that a
pathological case in today's world. Perl can always come to your
rescue in such situations.

Note the condition to avoid spawning off a sed when it's unnecessary.

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

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