[NTLUG:Discuss] Using test with multiple conditions
Leroy Tennison
leroy.tennison at verizon.net
Sat Mar 11 02:21:33 CST 2017
Thank you, you were right - trying too hard (that's me - if there's a
harder way to do it I'll find it!)
On 03/10/2017 08:23 AM, Eric Schnoebelen wrote:
> Leroy Tennison writes:
> - 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)
>
> [...]
>
> I think you're trying too hard. Since a2query is a program, you
> don't need to use test to evaluate its return value. Shell
> evaluation should be sufficent.
>
> eg:
> a2query -qc one || a2query -qc serve-cgi-bin
>
> If you need to wrap it in a conditional:
> if ( a2query -qc one || a2query -qc serve-cgi-bin); then
> :
> fi
>
> test(1) is more useful for testing for file existance, or if a
> variable is set, or the value of a variable (or program
> results.)
>
> I hope this helps,
> Eric
>
More information about the Discuss
mailing list