procmail
[Top] [All Lists]

Re: Procmail efficency? How do I make my .procmailrc more efficient?

1997-11-13 06:07:51
Scott Anguish wrote,

| I realized after I posted this, that I hadn't been very clear..
| 
| I'd like to have messages that have been sent to two mailing lists I'm on I  
| want  a copy put into EACH mailing list folder...

Yes, Scott; I understood, and Sean Straw did as well (Michael Stone probably
did, but his response didn't touch on it), because his answer takes care of
exactly that.

Sean's suggestion was to file lists based on a header added by the list
distribution mechanism, such as From_, Resent-Sender:, or X-Mailing-List:.
Say you belong to list foofoo and list barbar, and a message is sent to both.
Then the copy you receive via the foofoo list will have "foofoo" in the
headers added by the foofoo list and be file in your foofoo folder; the copy
you get via the barbar list will have "barbar" in the headers added by the
barbar list and be filed in your barbar folder.  To: and Cc: may name both
lists, but your recipes ignore them and focus instead on the list THROUGH
which you received the message.

I find that the double-reverse DeMorgan trick is good for these.  Say, for
example, that lists A, B, and C are identifiable by X-Mailing-List:; that
lists D, E, F, and G are identifiable by Resent-Sender:; and lists H and I
are identifiable only by From_.

  :0
  * ! ^X-Mailing-List: \/(A|B|C)
  * ! ^Resent-Sender: (owner-)?\/(D|E|F|G)
  * ! ^^From ([^ ]!)*(owner-)?\/(H|I)
  { } # procmail's no-op
  :0E                                        # :0E:
  | appnmail $MAILING_LIST_DIRECTORY/$MATCH  # $MATCH

| 
^TO\/(stepwise-talk-request|rhapsody-nda-request|rhapsody-nda|rhapsody-ui|webobjects|spamtools|rhapsody-dev|modperl|stepwise-talk|rhapsody-talk|next-prog|eof|dilbert_nextmail|omniweb-l|procmail|zsh-users|zsh-announce)

That can really be reduced a lot ... unless you want to do the lower-casing
within procmail.  However, if you use the list's added lines instead of those
supplied by the people who post, the case will always be the same, and you'll
need to do the lower-casing-without-a-fork trick only on lists where the
maintainer has a thing for capitals.

| > FOLDER=`echo $MATCH | tr 'A-Z' 'a-z'`

If you must do the lowercasing that way, at least do it only if there is a
capital letter present:

  FOLDER=$MATCH
  :0Dir
  * FOLDER ?? [A-Z]
  FOLDER=| echo $FOLDER | tr A-Z a-z

(You know, I'm thinking, if one has $SHELL set to ksh or bash, since echo|tr
 has to spawn a shell anyway [bash uses "declare" instead of "typeset",
 right?], you can do this and at least avoid forking tr:

  :0Dir
  * FOLDER ?? [A-Z]
  FOLDER=|typeset -l folder=$FOLDER ; echo $folder

Hmm.)