procmail
[Top] [All Lists]

Re: Putting some text into the Subject

1997-06-15 03:41:00
Sorry for following up on my own message, but I wasn't in shape on
Friday :-/

On Fri, 13 Jun 1997 17:14:07 +0300 (EET DST), I wrote:
   ^^^^^^^ (Friday the 13th, indeed!)
Here's an attempt which doesn't use external processes:

    :0
    * ^Subject: Read Receipt$
    * ^X-Prefiled: mailer
    * B ?? ^^( *$)*Your message regarding \/\
             .*$?.*[0-9][0-9]:[0-9][0-9]:[0-9][0-9] [ -+][0-9][0-9][0-9][0-9]
    {
        # Desired string is now in $MATCH but might contain newlines
        ... 

The * B ?? ^^... means, match from the start of the body of the
message. The regex is wired to allow empty whitespace before the
actual message, including newlines, and optionally one newline within
the match. 

If you really really want to have the full date in the reply, you'll
have to run the $MATCH through something like the tr command you had
(perhaps instead turning the newline into newline plus tab instead of
generating a single overlong header line), but frankly, I would think

For the record, you don't need tr for that:

    LINE="$MATCH"
    :0
    * LINE ?? ^^\/.*
    { FIRST="$MATCH" }
    :0
    * LINE ?? .$\/.*^^
    { LAST="$MATCH" }

    # Now, FIRST contains everything up to the line break, 
    # and LAST, everything after it (if anything)

    NEWSUBJ="$FIRST${LAST:+
        }$LAST"

The funny ${...} expression adds a newline and a tab if LAST is
defined, and nothing otherwise. (Is this implemented in Procmail
itself or does it depend on whether your shell implements it? I think
I've seen some /bin/sh which didn't understand this construct.)

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>