[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sh script Q



Quoth Ariel Biener on Tue, May 18, 1999:
> Which will result in the script fo fail if $PARAM is undefined.
> 
> Vadim's suggestion wasn't just a matter of semantics.

I don't think that on all Unices "$PARAM" (enclosed in double
quotes) will yield nothing.  On some Unices it will yield an
empty argument to [, so if $PARAM is undefined, the test will
look like:
[ "$PARAM" = "SOMETHING" ]	===>	[ "" = "SOMETHING" ]
which will lead to the correct result even when testing for an
empty string:
[ "$PARAM" = "" ]		===>	[ "" = "" ]
But it's safer to do it as I proposed, I think.

Anyway, does anybody in this world use 'test' instead of '['?

Vadik.

-- 
Bell Labs Unix -- Reach out and grep someone.