Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

test -z '(' : too many arguments



In the current git version of zsh, there is a funny bug with test (as
well as '['). If the arguments to 'test -z' or 'test -n' are exactly
equal to either '(' or ')', then a "too many arguments" error message is
produced.

The exit status is 1, and not 2 or higher (as POSIX says it must be when
'test' fails). This means 'test -n' gives an incorrect exit status for
these values, but 'test -z' doesn't.

Buggy output:

% test -z '('
test: too many arguments
% echo $?
1
% test -n '('
test: too many arguments
% echo $?
1
% test -z ')'
test: too many arguments
% echo $?
1
% test -n ')'
test: too many arguments
% echo $?
1

Correct output:

% test -n '(('
% echo $?
0
% test -n 'a(b'
% echo $?
0
% test -n '(a'
% echo $?
0
% test -n 'a('
% echo $?
0
% test -z 'a('
% echo $?
1
%



Messages sorted by: Reverse Date, Date, Thread, Author