procmail
[Top] [All Lists]

Re: alter subject line?

1999-08-20 19:01:04

Stan pointed out,

| It is probably worth noting that these two approaches will differ
| in their treatment of any mail that doesn't have a Subject: header.
| Specifically, Timothy's will insert
|    Subject: [shmoe]
| (give or take trailing white space), whereas David's will not add
| a Subject: at all.

... or for that matter, mine will also skip a message that has an empty
Subject: header.  I realized that and decided not to go into it.  If Joe
can't bring himself to supply an informative subject (or at least an en-
tertaining one, or one meaningful to aggarwal) on his mail, does it deserve
to be read at all?

So let's handle all cases, and also let's get rid of the unnecessary shell
invocation:

 :0
 * ^From:(_dot_)*joe(_at_)shmoe\(_dot_)com
 {
  savemetas=$SHELLMETAS
  SHELLMETAS # no shell for these brackets

  :0fwh # subject has at least one non-blank character
  * ^Subject:[  ]*\/[^  ].*
  | formail -I "Subject: [shmoe] $MATCH"
  :0Efwh # subject is blank, empty, or missing
  | formail -I "Subject: [shmoe]"

  SHELLMETAS=$savemetas
 }

The first pair of brackets in the condition line enclose space and tab; the
second enclose caret, space, and tab.

Here's an equivalent:

 :0
 * ^From:(_dot_)*joe(_at_)shmoe\(_dot_)com
 {
  MATCH # make sure it is unset

  :0 # if subject has at least one non-blank character, set $MATCH
  * ^Subject:[  ]*\/[^  ].*
  { }

  savemetas=$SHELLMETAS # no shell for these brackets
  SHELLMETAS

  :0fwh
  | formail -I "Subject: [shmoe]${MATCH:+ $MATCH}"

  SHELLMETAS=$savemetas
 }
 

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