Subject: Quick Question

From: Jeremy Mathers <[email-masked]>
Date: Wed, 26 Apr 1995 11:56:22 -0500

What is the best method to "trim" a subject line?
Currently, I run a lot of mailing list mail through a rule like the one
shown below:

:
^From.*procmail
| formail -k -X "From " -X From: -X Subject: >> ProcMail

Now, suppose I wanted to "trim" the subject lines, say removing all the
vowels.  I want to do something like:

	SUBJECT=`sed s/[aeiouAEIOU]//`

Can I do it in place?  Suggestions?

Also, should the above rule have a lockfile?  (Note that if I use "::"
like I do with all my other rules, it complains.)  Should I use something
like ":proclock"?

---

From: [email-masked] (David W. Tamkin)
Date: Wed, 26 Apr 1995 14:54:39 -0500 (CDT)

Jeremy Mathers asked,

| What is the best method to "trim" a subject line?
| Currently, I run a lot of mailing list mail through a rule like the one
| shown below:
|
| :
| ^From.*procmail
| | formail -k -X "From " -X From: -X Subject: >> ProcMail
|
| Now, suppose I wanted to "trim" the subject lines, say removing all the
| vowels.  I want to do something like:
|
| 	SUBJECT=`sed s/[aeiouAEIOU]//`
|
| Can I do it in place?  Suggestions?

What do you mean by "in place"?  You mean on the way into $MAILDIR/ProcMail
without using a separate filtering recipe first?  Heck, why not:

  :: # -XFrom extracts both "From " and "From:" since version 2.9something
  * condition
  | formail -k -XFrom -XSubject: | sed -e '/^$/,$ b' -e '/^Subject:/!b' \
    -e 's/[AEIOUaeiou]//g' -e 's/^Sbj/Subje/' >> ProcMail

| Also, should the above rule have a lockfile?  (Note that if I use "::"
| like I do with all my other rules, it complains.)  Should I use something
| like ":proclock"?

It absolutely should have a local lockfile.  I don't understand why procmail
complains about a simple "::" (at least, I don't know why it complains about
lack of an implicit lockfile name; if there is some OTHER complaint, that's
another story), since the ">>" redirector clearly indicates a default name.

Here's another way that may be easier to read and moreover doesn't depend on
canonical capitalization of the word "Subject:" in the incoming text:

  :0 # no local lockfile here
  * condition
  { NEWSUBJECT=`formail -x Subject: | tr -d AEIOUaeiou`

    :0: # $MAILDIR/ProcMail.lock is implicit name for local lockfile
    | formail -I"Subject:$NEWSUBJECT" -k -XFrom -XSubject: >> ProcMail
  }