[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wrong logical evaluation of expressions involving true or false comm
Re: wrong logical evaluation of expressions involving true or false commands
Mon, 25 Jun 2007 21:39:24 -0400
Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux)
Matthew Woehlke <address@hidden> wrote:
> Stephane Chazelas wrote:
>> [ -n "$foo" -a -n "$bar" ]
>> is not the expression to test whether both "$foo" and "$bar" are
>> non-empty, as it would fail for some specific values of $foo or
>> $bar (try it when $foo contains "=" for instance).
> Huh? Why would having an '=' in foo have any effect?
I think Stephane meant the exact string "=", not any string containing
> "$foo" is still a string, it should not be subject to word splitting
Right, but it is special to the test/[ command.
$ [ -n = -a -n z ]
bash: [: too many arguments
Here, "=" is interpreted as a binary operator, not as the operand of