bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bugs in test


From: Paul Eggert
Subject: Re: bugs in test
Date: Wed, 11 Jan 2006 11:36:06 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Eric Blake <address@hidden> writes:

> First, the 'extra argument' and 'missing argument' error messages are
> missing a trailing newline.

Thanks.  That's a bug, and I installed the obvious patch.

> Second, it is confusing that -a is silently accepted, but that non-unary
> operators that look like an operator, such as -q, get a different error
> message than non-unary operators that are completely random, which are yet
> different from the special cases of -o and -N.

I suppose it might be nicer to generate more-consistent diagnostics, yes.

> The POSIX violation comes in when you now try to negate these tests:
>
> $ /bin/test ! -a ChangeLog ; echo $?
> 1
> $ /bin/test ! -o ChangeLog ; echo $?
> /bin/test: extra argument `-o'2

I see your point on these.  I think the current code was written
before -o and -a were required by POSIX, and it is correct for the
POSIX 1003.2-1992 standard.  For 'test', the current standard has two
options: base, and with the XSI extensions.  As I read it, coreutils
'test' conforms to the base standard, but violates the combination
of the standard plus the XSI extensions.

It seems very odd that the XSI extension would alter the behavior
of a base command, in such a way that it should produce the negation
of the value that it would otherwise produce.  I suspect that this
was not intended, and it's likely a bug in the standard.  At the
very least, the point should be cleared up.

Can you propose an Aardvark on this issue?  A survey of existing
implementations might help.  My guess is that the result will come
back that the existing standard is contradictory, and that
implementations can do things either way.

There's also the issue of what is the "right" thing to do.

> $ /bin/test ! = ! ; echo $?
> 0

POSIX requires this behavior, since the first clause applies:
"If $2 is a binary primary, perform the binary test of $1 and $3."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]