|
From: | Matthew Woehlke |
Subject: | Re: wrong logical evaluation of expressions involving true or false commands |
Date: | Mon, 25 Jun 2007 19:42:52 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070509 Thunderbird/1.5.0.12 Mnenhy/0.7.4.0 |
Stephane Chazelas wrote:
And it should be noted (and it's noted as well in the page you're refering to) that while the above is true for strings such as "foo" and "bar", it is not true in the general case. [ -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? "$foo" is still a string, it should not be subject to word splitting (unless you slapped an 'eval' in front of the mess, but then you have some *serious* quoting issue).
IOW, I do not see any case in which this could return non-zero: argv[0] = "[" argv[1] = "-n" argv[2] = some string with '=' argv[3] = "-a" argv[4] = "-n" argv[5] = some other non-empty string that might have an '=' argv[6] = "]" -- Matthew What, no punchline?
[Prev in Thread] | Current Thread | [Next in Thread] |