Re: /bin/sh diversions
02-08-2007, Peter Samuelson:
>
> [Pierre Habouzit]
>> the 3 biggest problems I've seen are:
>>=20
>> * [[ for test, trivial: add it as a test alias, and also check for ]]
>> termination in the test.c builtin.
>
> Ummm, [[ is not the same as [. (If they were the same, there would
> have been no need to invent [[.) They behave quite differently with
> regard to argument quoting. Try this in bash:
>
> unset foo
> [ -n $foo ] && echo foo is non-empty
> [[ -n $foo ]] && echo foo is non-empty
>
> As you can see, only the second one works.
Not quoting possible empty argument is a script writing bug. It's like
dereferencing NULL pointer and must be shot away also. Supporting
buggy scripting by inventing new tools is struggling with consequences
not cause and is a very bad idea.
BTW, i've provided patch in the BTS for dash's test built-in to have
arithmetic checking of an empty argument and zero right. This was nearly
a month ago, yet nothing happened. (Flaming about dash is easy,
maintaining is not :)
____
Reply to: