История изменений
Исправление aedeph_, (текущая версия) :
http://www.tldp.org/LDP/abs/html/comparison-ops.html
-n
string is not null.
Caution
The -n test requires that the string be quoted within the test brackets. Using an unquoted string with ! -z, or even just the unquoted string alone within test brackets (see Example 7-6) normally works, however, this is an unsafe practice. Always quote a tested string. [1]
Notes [1]
As S.C. points out, in a compound test, even quoting the string variable might not suffice. [ -n «$string» -o «$a» = «$b» ] may cause an error with some versions of Bash if $string is empty. The safe way is to append an extra character to possibly empty variables, [ «x$string» != x -o «x$a» = «x$b» ] (the «x's» cancel out).
Исходная версия aedeph_, :
http://www.tldp.org/LDP/abs/html/comparison-ops.html
-n
string is not null.
Caution
The -n test requires that the string be quoted within the test brackets. Using an unquoted string with ! -z, or even just the unquoted string alone within test brackets (see Example 7-6) normally works, however, this is an unsafe practice. Always quote a tested string. [1]