Expanding undefined variables within a shell
Within a shell, what is the difference between [ -n undefinedString ] and [ -n "$undefinedString" ] ?
With bash I get:
$ unset undefinedString
$ [ -n undefinedString ] && printf "$undefinedString" | od -c
0000000
$ [ -n "$undefinedString" ] && printf "$undefinedString" | od -c
$ [ -z "$undefinedString" ] && printf "$undefinedString" | od -c
0000000
I mean, shouldn't [ -n undefinedString ], which I guess is without shell expansion, give an error? Clearly
it is an empty string.
I think I am confusing various terms. An explanation, perhaps by using the concept of C like strings,
might be helpful.
Reply to: