On Sat, 1 Dec 2018, Dmitry Bogatov wrote:

> AFAIK, in shell [ "${foo}" ] is equal to [ -n "${foo}" ].

Not always / portably.


I recommend

        test -n "$foo"

for POSIX (which is equivalent to [ -n "$foo" ] but better legible and
making it clear that test is an external command, not a language con‐
struct), and

        [[ $foo ]]

for Korn shell and compatibles, including (here) GNU bash.

bye,
//mirabilos (mksh developer)
-- 
15:41⎜<Lo-lan-do:#fusionforge> Somebody write a testsuite for helloworld :-)

Reply via email to