procmail
[Top] [All Lists]

Re: testing and assigning in one conditional?

2001-08-25 10:56:19
John Conover <conover(_at_)rahul(_dot_)net> writes:
The following fragment tests to see if an address is in a database,
and then if it is, assigns the address to the variable $SENDER.

   :0
   * ? /home/john/receivedAddressdb "${HOME}/address.db"
   {
      :0 whc
      SENDER=| /home/john/receivedAddressdb "${HOME}/address.db"
      :0 whf
      | formail -I "Envelope-To: $SENDER"
   }

Is it possbile to do the test and assigment in one statement?

Yes.  The 'w' flag tells procmail to check the exit code of the action
and treate the recipe as failed if the exitcode isn't zero.  The 'a'
flag can then be used on the next recipe to only execute it if the
previous recipe's action succeeded.  Therefore, the following should work:

        :0 wh
        SENDER=| /home/john/receivedAddressdb "${HOME}/address.db"

        :0 whfa
        | formail -I "Envelope-To: $SENDER"


Note that the 'c' flag is superfluous on variable capture recipes.
Indeed, you should be getting "Extraneous copy-flag ignored" messages
in your logfile from that recipe.


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>