[NTLUG:Discuss] Using test with multiple conditions

Ralph Green sirable at gmail.com
Fri Mar 10 02:13:23 CST 2017


Leroy,

test $(a2query -qc one) -o $(a2query -qc two);echo $?    $? is zero
(wrong since neither one or two are found)

test `a2query -qc one` -o `a2query -qc two`;echo $?    $? is zero
(wrong since neither one or two are found)

These two make sense.  If neiither one or two is found, then both
expressions evaluate to false.  and expression1 -o expression2  with
both false is false.  If either had been true, the overall result
would have been true.

test a2query -qc one -o a2query -qc serve-cgi-bin;echo $?    bash
replies "too many arguments"
 Right, also.  test doesn't know where your expression is, so it sees
way too many arguments.

test eval "a2query -qc one" -o eval "a2query -qc serve-cgi-bin";echo
$?    bash replies "too many arguments"
 Right, also.  eval "a2query -qc one" is the first expression. Then,
the -o argument.  And, then the rest does not look like an expression.
It looks like 2 or 3 expressions and another argument.  All that is
too many args for test.

Good day,,
Ralph



More information about the Discuss mailing list