zsh-workers
 help / color / mirror / code / Atom feed
* test -z '(' : too many arguments
@ 2015-05-27 18:40 Martijn Dekker
  2015-05-27 20:23 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Martijn Dekker @ 2015-05-27 18:40 UTC (permalink / raw)
  To: zsh-workers

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
%


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-27 20:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 18:40 test -z '(' : too many arguments Martijn Dekker
2015-05-27 20:23 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).