bug#69939: test utility bug: "test -a -a -a" and "test -o -o -o" fail

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
Vincent Lefevre <[email protected]> wrote:

> With GNU Coreutils 9.4, both "test -a -a -a" and "test -o -o -o" fail:
> 
> $ export POSIXLY_CORRECT=1
> $ /usr/bin/test -a -a -a ; echo $?
> /usr/bin/test: ‘-a’: unary operator expected
> 2
> $ /usr/bin/test -o -o -o ; echo $?
> /usr/bin/test: ‘-o’: unary operator expected
> 2
> 
> According to POSIX, they should return 0.
> 
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
> says for 3 arguments:
> 
>   If $2 is a binary primary, perform the binary test of $1 and $3.
> 
> Here, $2 is -a and -o respectively, which are binary primaries.
> And both $1 and $3 are non-null strings.

Just adding here that POSIX.1-2024 removed the -a and -o operators [1]:

    Austin Group Defect 1330 is applied, removing the obsolescent (and
    optional) -a and -o binary primaries, and '(' and ')' operators.

So I don't think we should spend much time worrying about it. That is my
excuse at least.

Will leave this bug report open though.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/test.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.