bug-coreutils
[Top][All Lists]
Advanced

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

bug#33097: test has filetest -a but man page doesn't list it


From: Martin Schulte
Subject: bug#33097: test has filetest -a but man page doesn't list it
Date: Sun, 21 Oct 2018 10:29:09 +0200

Hello!

Paul Eggert wrote:
> Bernhard Voelker wrote:
> > I don't think we can remove that primary without breaking some
> > scripts, so it's probably best to document it.
> 
> I have the opposite impression. Any scripts using this confusing -a
> operator are already broken, and we should phase it out. Not that
> anybody actually *uses* coreutils "test -a".

I second this - but I think it's even more important that the test from
coreutils and the bash builtin behave/are documented the same way.

"help test" lists "-a" as file test, but when negated the bash builtin
behaves different ("wronger" from my point of view) than the coreutils
version (and even different from the "-e" in both implementations) - see
attached output.

coreutils: test ! -a file -> test ! ( -a file )
bash: test ! -a file -> test ( ! ) -a ( file )

Best regards,

Martin

address@hidden:~/langs/sh$ cat minus-a 
#!/bin/bash

set -o nounset

file=/etc/passwd

echo $BASH_VERSION
/usr/bin/[ --version | head -1

for cmd in test /usr/bin/test
do
  for op in -a -e
  do
    printf "%-30s -> " "$cmd ! $op $file" ; $cmd ! $op $file ; echo $?
  done
done | cat -n
address@hidden:~/langs/sh$ ./minus-a 
4.4.12(1)-release
[ (GNU coreutils) 8.26
     1  test ! -a /etc/passwd          -> 0
     2  test ! -e /etc/passwd          -> 1
     3  /usr/bin/test ! -a /etc/passwd -> 1
     4  /usr/bin/test ! -e /etc/passwd -> 1





reply via email to

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