@dchirikov, that's because in the second one, you forgot to quote the command substitution, so it ended up being [ -n ], the same [ -n -n ]. In shells other than zsh, command (even builtin) arguments or shell variables can't contain NUL characters.
–
Stéphane ChazelasJan 30 '13 at 20:29

2 Answers
2

[ "$var" ] is equivalent to [ -n "$var" ] in bash and most shells nowadays. In other older shells, they're meant to be equivalent, but suffer from different bugs for some special values of "$var" like =, ( or !.

I find [ -n "$var" ] more legible and is the pendant of [ -z "$var" ].

[[ -n $var ]] is the same as [[ $var ]] in all the shells where that non-standard ksh syntax is implemented.

test "x$var" != x would be the most reliable if you want to be portable to very old shells.