Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
test -z '(' : too many arguments
- X-seq: zsh-workers 35301
- From: Martijn Dekker <martijn@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: test -z '(' : too many arguments
- Date: Wed, 27 May 2015 20:40:42 +0200
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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