procmail
[Top] [All Lists]

Re: howto handle case

2001-09-13 20:33:42
Rino Mardo <rmardo(_at_)yahoo(_dot_)com> writes:
hi.  i have this recipe:

:0
* ^TO_\/(debian-user|ph-linux-newbie|plug|mutt-users|procmail|ph-isp|ph-mis=
c)@
* MATCH ?? ()\/[^(_at_)]+
$MAILDIR/$MATCH/

it works fine as long as the list addresses are in lower case.  then
some windows user used an all caps "PH-ISP" and it blew my nicely
crafted maildir structure as i ended up with a "ph-isp" and "PH-ISP"
directories.

how can procmail be directed not to case-sensitive?

To quote the procmailrc(5) manpage:

       D    Tell the internal egrep to distinguish between  upper
            and  lower  case (contrary to the default which is to
            ignore case).

So:
    :0 D
    * ^TO_\/(debian-user|ph-linux-newbie|plug|mutt-users|\
             procmail|ph-isp|ph-misc)@
    * MATCH ?? ()\/[^(_at_)]+
    $MAILDIR/$MATCH/

However, a better solution is to map the matched text to lowercase.
This requires a variable holding all the alternatives in the desired case.
We then treat the matched text (possibly in mixed case) as a regexp to
match against the text in the correct case.

    # Do _not_ optimize this as a regexp: we need all the words written out
    lists="debian-user|ph-linux-newbie|plug|mutt-users|procmail|ph-isp|ph-misc"

    :0
    * $ ^TO_\/($lists)@
    * MATCH ??   ()\/[^(_at_)]+
    * lists ?? $ ()\/$\MATCH
    $MATCH/


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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