procmail
[Top] [All Lists]

Re: Convert $MATCH to lowercase?

1997-01-23 16:07:08
Louis-David Mitterrand asked,

| I use the following recipe to store mailing list messages in specific
| folders:
|
| :0:
| * ^TO.*\/(kernel|x11|mutt|procmail|zsh|laptop|jdbc|vimdev)

First, don't use "^TO.*"; the expansion of "^TO" already ends in something
better than ".*", and adding ".*" weakens it.

| * !^TOmito@
| * !^From:.*(linus|torvalds)
| * !^References:(_dot_)*mito(_at_)retriever
| $MATCH
|
| The only problem is sometimes someone writes to (for example) Mutt-user
| instead of mutt-user and I get two folders. How do I convert the
| '$MATCH' to lower-case before writing the folder?

As much as I wish this could be done without running an outside program, all
I can come up with is the way I do it myself, which, adapted to Louis-David's
recipe, comes out like this:

  :0
  * ^TO\/(kernel|x11|mutt|procmail|zsh|laptop|jdbc|vimdev)
  * !^TOmito@
  * !^From:.*(linus|torvalds)
  * !^References:(_dot_)*mito(_at_)retriever
  { FOLDER=$MATCH

   :0D: # D flag makes regexps case-sensitive.
   * ! FOLDER ?? [A-Z]
   $FOLDER
   :0Ehi # catch only elses and not errors
   folder=|echo $FOLDER | tr A-Z a-z
# Some versions of tr require this syntax:
#  folder=|echo $FOLDER | tr '[A-Z]' '[a-z]'
# If you don't have tr, try this:
#  folder=|echo $FOLDER | sed -e \
#          'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'
   :0A:
   $folder
  }

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