procmail
[Top] [All Lists]

Re: multiple 'test -x '

1997-06-06 12:48:00
Timothy Luoma <luomat(_at_)peak(_dot_)org> writes:

I'll note that your logic is reversed: you should be and'ing, not or'ing.

I don't think so.... any one of those files missing should stop the entire
process, therefore it should be 

if x is not executable or if y is not executable or if z is not executable

Should I use

:0
* ? test -x $APPNMAIL || test -x $FORMAIL || test -x $GREP
{
      recipe

}

No.  That will execute the recipe if any of the files *is* executable.
You want the recipe to execute if any of the files are *not* executable.

        :0
        * ? test ! -x $APPNMAIL || test ! -x $FORMAIL || test ! -x $GREP
        {
            recipe
        }

"If $APPNMAIL isn't executable, or if $FORMAIL isn't executable, or if
$GREP isn't executable, then process the action."

By applying DeMorgans's laws you can extract out the negations.
(DeMorgan's laws: "(NOT A) OR (NOT B) is equivalent to NOT (A AND B), and
(NOT A) AND (NOT B) is equivalent to NOT (A OR B)").

        :0
        * ! ? test -x $APPNMAIL && test -x $FORMAIL && test -x $GREP
        {
            recipe
        }

"If it's not true that all of $APPNMAIL, $FORMAIL, and $GREP are executable,
then process the action."


Philip Guenther

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