[NTLUG:Discuss] Using test with multiple conditions

Leroy Tennison leroy.tennison at verizon.net
Thu Mar 9 22:25:59 CST 2017


I haven't been able to determine where the problem is, I'm either 
getting bash errors or a uniform result when it should be changing.  
What I'm trying to get is a zero return code when either test returns a 
zero return code or a non-zero return code otherwise.  The test in this 
case is "a2query -qc <configuration name>'.  This apache program, with 
-qc, is supposed to return zero if the configuration name is found and 1 
otherwise.  What I've tried so far is:

test $(a2query -qc one) -o $(a2query -qc serve-cgi-bin);echo $?    $? is 
zero (correct since serve-cgi-bin is found)

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)

test a2query -qc one -o a2query -qc serve-cgi-bin;echo $?    bash 
replies "too many arguments"

test eval "a2query -qc one" -o eval "a2query -qc serve-cgi-bin";echo 
$?    bash replies "too many arguments"

'man test' shows "EXPRESSION1 -o EXPRESSION2", what am i doing wrong?

Thanks for your help.




More information about the Discuss mailing list