procmail
[Top] [All Lists]

Re: Simple Bozo-Filter Example? (fwd)

1997-02-13 09:26:32
era eriksson <reriksso(_at_)cc(_dot_)helsinki(_dot_)fi> writes:
Just add a check for whether the killfile actually exists, as a
precaution. 

   FROM=`formail -rzxTo:`
   EGREP=/usr/local/bin/egrep
   :0
   * ? echo "$FROM" | $EGREP -i -f $HOME/email.killfile
   {

Add a couple of things around the :0, like so:

KILLFILE=$HOME/email.killfile
:0
* ? test -r $KILLFILE -a -s $KILLFILE
* ? echo "$FROM" | $EGREP -i -f $KILLFILE
{
# etc
 :
 :

Hope your test(1) is in your path and understands these funny
switches. (I just tried this quickly with Bash and GNU test but they
are of course not the most plain-jane versions around.)

Two suggestions:

1)      You way want to reverse the order of the condition if you
        expect the killfile to usually be non-empty, that'll save a
        test in the usual case.

2)      If you don't use the FROM variable anywhere else in the .procmailrc,
        you can integrate it into the condition:


        KILLFILE = $HOME/email.killfile
        :0
        * ? formail -rzxTo: | egrep -i -f $KILLFILE
        * ? test -r $KILLFILE -a -s $KILLFILE
        {
            # etc
        }


Philip Guenther