procmail
[Top] [All Lists]

Re: procmail and ifile

2002-08-20 05:59:18
[ObDigression: skip reading this if you have no interest in Bourne-
shell scripting.]

From: parv <parv_fm(_at_)emailgroups(_dot_)net>

i almost missed the back-quotes.  if "$()" construct had been used
instead, i wouldn't have to re-read 4-5 times just to reconcile the
interaction between "[" (test) & the external commands.

True (and the original is admittedly messy to the point of being
creepy); but not all sh's understand $().


  #!/bin/sh
  PATH=/usr/bin:/usr/local/bin

  { ifile -q -v 0 | grep -q '^spam' ; }  &&  exit 0
  exit 1

I have no idea what ifile is; but, gee, the standard exit
code for a script is exit 0.  We shouldn't have to bother
to set that explicitly.

Assuming a POSIX-compatible grep (see "man grep" for cautions
about the -s and -q flags), how about

   { ifile -q -v 0 | grep -qs '^spam' ; } || exit 1

But come to think of it, grep applies a proper exit code
implicitly.  This should work:

   ifile -q -v 0 | grep -qs '^spam'


So why do we need a script?

        :0 flags
        * ? ifile -q -v 0 | grep -qs '^spam'
        { your action on success }

-- 
dman

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