procmail
[Top] [All Lists]

Re: More compact mailing list filter?

1997-09-15 11:35:55
Lars Hecking suggested to Steven Whatley,

| # Some external lists
| :0:
| * ^TO_\/(aminet-weekly|mutt-users|procmail)
| IN."`/bin/echo ${MATCH} | /bin/tr A-Z a-z`"
|
|  The tr command is there to make sure that everything is in lowercase.
|  Otherwise, I might get more than one IN.* box for the same list when
|  ppl send mail to procmail(_at_)(_dot_)(_dot_)(_dot_), 
Procmail(_at_)(_dot_)(_dot_)(_dot_), ProcMail(_at_)(_dot_)(_dot_)(_dot_) etc.

For now, I'll not get into the general advisability or inadvisability of
recognizing a mailing list by a match to ^TO_; this is about tr.

At the least, use tr only when it is needed:

  :0
  * ^TO_\/(aminet-weekly|mutt-users|procmail)
  { LIST=$MATCH

    :0Dhir
    * LIST ?? [A-Z]
    LIST=| echo $LIST | tr A-Z a-z

    :0:
    IN.$LIST
  }

But I believe that the translation can be done within procmail and not need
to fork a shell and tr:

  LISTS="(aminet-weekly|mutt-users|procmail)" # cases desired for foldernames
  :0:
  * $ ^TO_\/$LISTS
  * $ LISTS ?? ()\/$\MATCH
  IN.$MATCH

As I file mail from lists by headers that are added by the list software
(such as From_ or Resent-Sender:), I can't test it for myself on this list. 
[I can for the SmartList list, because its headers say "SmartList" and my
folder for it is named "smartlist"].

For older versions of procmail that have extraction but don't let you use
it twice in one recipe (in which case they don't support ^TO_ either),

  LISTS="(aminet-weekly|mutt-users|procmail)" # cases desired for foldernames
  :0
  * $ ^TO\/$LISTS
  { LIST=$MATCH }
   :0A:
   * $ LISTS ?? ()\/$\LIST
   IN.$MATCH

However, the trick works only for canonicalizing the case, not for removing
hyphens or anything else.