“Tony” <mts.spb.suxx@mail.ru> wrote in message
news:opsmmz6dafo93ri4@mobile…
On Tue, 22 Feb 2005 10:52:51 -0500, Wojtek Lerch <> Wojtek_L@yahoo.ca
wrote:
Because field splitting is done after parameter expansion. To ensure
that a string is parsed as a single argument even if it’s empty or
contains spaces, you need to put it in quotes:
if [ -z “$STRING1” -a -z “$STRING2” ]; …
I was "copy-paste"ing the script text from some UNIX cookbook… Neither
I guess it wasn’t a very good cookbook…
QNX’s help system regarding “sh” and scripting tells about quotes.
On my machine, the sh help page is rather long and does talk about quoting;
but I just took a quick look and didn’t find a specific warning about this
particular issue. But I don’t think the help page was meant as a tutorial
for complete beginners…
Is it the difference between UNIX’s ksh and the QNX’s clone?
Any POSIX shell must do field splitting after parameter expansion. The only
choice POSIX gives shells in this case is what to do when you use invalid
arguments. When the strings are empty, your original command is equivalent
to
if [ -z -a -z ]
and since that’s invalid, it’s up to the shell whether to give you an error
message and whether to return success or failure.
But it’s not about QNX vs. the rest of the world. For instance, this guy
was bitten by this on Solaris:
http://tinyurl.com/6jpgy
BTW Even though the QNX4 shell is not 100 per cent POSIX, you might be
interested in how POSIX defines the shell language:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02