Reputation: 23876
In some ancient Shell scripts for Solaris I found the following notation to check if a variable is empty:
[ x"$var" = x ]
On a current Linux system I would write it just as
[ "$var" = "" ]
or
[ -z "$var" ]
Which version of [
actually requires the first notation?
Upvotes: 1
Views: 279
Reputation: 1746
None.The alias from [] to test appears after the option -z of test. Therefore, if you can use [ x"$var" = x]
, you can also write [ -z "$var" ]
.
Upvotes: 1