GNU bug report logs -
#33097
test has filetest -a but man page doesn't list it
Previous Next
Reported by: Martin Schulte <gnu <at> schrader-schulte.de>
Date: Fri, 19 Oct 2018 21:00:02 UTC
Severity: normal
Tags: confirmed, fixed
Merged with 15278
Done: Bernhard Voelker <mail <at> bernhard-voelker.de>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33097 in the body.
You can then email your comments to 33097 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Fri, 19 Oct 2018 21:00:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Martin Schulte <gnu <at> schrader-schulte.de>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 19 Oct 2018 21:00:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello coreutils maintainers,
test in coreutils 8.30 supports the unary -a test (is the same as -e) but
this is not listed on the manpage (in bash 4.4.12 "help test" does list
it).
I can imagine good reasons to kick out the unary -a but I think it
then should be kicked out of program and man page (or it should be listed
in the man page, maybe as deprecated).
Best regards,
Martin
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Fri, 19 Oct 2018 22:57:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 33097 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 10/19/18 10:48 PM, Martin Schulte wrote:
> Hello coreutils maintainers,
>
> test in coreutils 8.30 supports the unary -a test (is the same as -e) but
> this is not listed on the manpage (in bash 4.4.12 "help test" does list
> it).
>
> I can imagine good reasons to kick out the unary -a but I think it
> then should be kicked out of program and man page (or it should be listed
> in the man page, maybe as deprecated).
Good spot, thanks for the report.
The '-a FILE' primary is supported since "the beginning", and even the
POSIX spec mentions this unlucky thing:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
An early proposal used the KornShell -a primary (with the same meaning),
but this was changed to -e because there were concerns about the high
probability of humans confusing the -a primary with the -a binary operator.
I don't think we can remove that primary without breaking some scripts,
so it's probably best to document it.
The attached, proposed patch add documentation both in the man and
texinfo format.
Comments?
Have a nice day,
Berny
[0001-doc-document-highly-discouraged-test-a-FILE-primary.patch (text/x-patch, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Fri, 19 Oct 2018 23:10:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 33097 <at> debbugs.gnu.org (full text, mbox):
Hi Bernhard,
On 19/10/18 04:56 PM, Bernhard Voelker wrote:
> On 10/19/18 10:48 PM, Martin Schulte wrote:
>
> The '-a FILE' primary is supported since "the beginning", and even the
> POSIX spec mentions this unlucky thing:
[...]
> I don't think we can remove that primary without breaking some scripts,
> so it's probably best to document it.
> The attached, proposed patch add documentation both in the man and
> texinfo format.
>
> Comments?
>
I just noticed this old bug:
https://bugs.gnu.org/15278
Where Eric notes that coreutils' unary -a is incorrect under some very
specific circumstances - perhaps it's worth mentioning that as well
(unless someone wants to fix it, though it's been 5 years...)
-assaf
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Sun, 21 Oct 2018 00:11:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 33097 <at> debbugs.gnu.org (full text, mbox):
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".
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Sun, 21 Oct 2018 08:30:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 33097 <at> debbugs.gnu.org (full text, mbox):
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
schulte <at> martnix4:~/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
schulte <at> martnix4:~/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
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Sun, 21 Oct 2018 08:40:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 33097 <at> debbugs.gnu.org (full text, mbox):
Hello again!
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".
Maybe even more important than the previous arguments - there's no
filetest "-a" in the POSIX standard:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
Best regards,
Martin
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Sun, 21 Oct 2018 23:08:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 33097 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 10/21/18 2:09 AM, Paul Eggert wrote:
> 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".
Done with the attached 1st patch.
The 2nd patch is a cleanup avoiding the redundant checking of unary operators
in test_unop and unary_operator.
The 3rd patch adds support for 'test -N FILE' as in bash.
Please check (on various platforms / file systems if possible).
Thanks & have a nice day,
Berny
[0001-test-remove-support-for-the-ambigous-a-unary-operato.patch (text/x-patch, attachment)]
[0002-test-simplify-redundant-code.patch (text/x-patch, attachment)]
[0003-test-add-N-unary-operator.patch (text/x-patch, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Mon, 22 Oct 2018 06:17:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 33097 <at> debbugs.gnu.org (full text, mbox):
Hi Assaf,
On 10/20/18 1:09 AM, Assaf Gordon wrote:
> Hi Bernhard,
>
> On 19/10/18 04:56 PM, Bernhard Voelker wrote:
>> On 10/19/18 10:48 PM, Martin Schulte wrote:
>>
>> The '-a FILE' primary is supported since "the beginning", and even the
>> POSIX spec mentions this unlucky thing:
> [...]
>> I don't think we can remove that primary without breaking some scripts,
>> so it's probably best to document it.
>> The attached, proposed patch add documentation both in the man and
>> texinfo format.
>>
>> Comments?
>>
>
> I just noticed this old bug:
> https://bugs.gnu.org/15278
>
> Where Eric notes that coreutils' unary -a is incorrect under some very
> specific circumstances - perhaps it's worth mentioning that as well
> (unless someone wants to fix it, though it's been 5 years...)
thanks for mentioning. Now, this bug would go away with the proposed
patch #1 in [1] to remove the -a unary operator.
FWIW: bash also has a 'test -o SHELLOPT' unary operator to test whether
the given SHELLOPT is enabled in the current shell (see 'set -o SHELLOPT').
GNU test also had this -o unary (until patch #2 in [1]), but this never
worked well because it ran into an error later on because it ran into
thee default case and therefore didn't call 'unary_advance'.
[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=33097#23
Have a nice day,
Berny
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Mon, 22 Oct 2018 12:12:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 33097 <at> debbugs.gnu.org (full text, mbox):
On 21/10/18 16:06, Bernhard Voelker wrote:
> On 10/21/18 2:09 AM, Paul Eggert wrote:
>> 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".
>
> Done with the attached 1st patch.
>
> The 2nd patch is a cleanup avoiding the redundant checking of unary operators
> in test_unop and unary_operator.
>
> The 3rd patch adds support for 'test -N FILE' as in bash.
> Please check (on various platforms / file systems if possible).
Very nice.
atime has 24 hour resolution on vfat I think,
though I think your test should handle that.
Also -N should work with common relatime mount option.
thanks!
Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Mon, 22 Oct 2018 20:19:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 33097 <at> debbugs.gnu.org (full text, mbox):
On 10/22/18 2:11 PM, Pádraig Brady wrote:
> On 21/10/18 16:06, Bernhard Voelker wrote:
>> On 10/21/18 2:09 AM, Paul Eggert wrote:
>>> 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".
>>
>> Done with the attached 1st patch.
>>
>> The 2nd patch is a cleanup avoiding the redundant checking of unary operators
>> in test_unop and unary_operator.
>>
>> The 3rd patch adds support for 'test -N FILE' as in bash.
>> Please check (on various platforms / file systems if possible).
>
> Very nice.
> atime has 24 hour resolution on vfat I think,
> though I think your test should handle that.
Thanks for the review - indeed, see:
https://en.wikipedia.org/wiki/File_Allocation_Table#Directory_table
Date resolution
2 seconds for last modified time,
10 ms for creation time,
1 day for access date,
2 seconds for deletion time
Although I think it's unlikely that someone will dare to run the coreutils
test-suite on vfat, I'd change the atime/mtime to set back in the test
to 2 resp. 4 days:
--- a/tests/misc/test-N.sh
+++ b/tests/misc/test-N.sh
@@ -24,13 +24,13 @@ touch file || framework_failure_
stat file
returns_ 1 env test -N file || fail=1
-# Set access time to yesterday at noon: 'test -N' returns 0.
-touch -a -d "12:00 today -1 days" file || framework_failure_
+# Set access time to 2 days ago: 'test -N' returns 0.
+touch -a -d "12:00 today -2 days" file || framework_failure_
stat file
env test -N file || fail=1
-# Set mtime to the day before yesterday: 'test -N' returns 1;
-touch -m -d "12:00 today -2 days" file || framework_failure_
+# Set mtime to 2 days before atime: 'test -N' returns 1;
+touch -m -d "12:00 today -4 days" file || framework_failure_
stat file
returns_ 1 env test -N file || fail=1
> Also -N should work with common relatime mount option.
What do you mean exactly? I mean, -N just reads what is stored in the
file system, so there's nothing 'test' could do about it.
Well, we could include a note to the texinfo page that -N
heavily relies on the underlying file system and mount option.
Thanks & have a nice day,
Berny
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#33097
; Package
coreutils
.
(Tue, 23 Oct 2018 00:19:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 33097 <at> debbugs.gnu.org (full text, mbox):
On 21/10/18 05:06 PM, Bernhard Voelker wrote:
> The 3rd patch adds support for 'test -N FILE' as in bash.
> Please check (on various platforms / file systems if possible).
"test-N.sh" passes on FreeBSD,OpenBSD,NetBSD (with their respective
default file systems) and on cygwin 64bit over ntfs.
Also passes on ext4 inside a directory with "chattr +A" (disabled access
time).
-assaf
Reply sent
to
Bernhard Voelker <mail <at> bernhard-voelker.de>
:
You have taken responsibility.
(Fri, 26 Oct 2018 11:59:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Martin Schulte <gnu <at> schrader-schulte.de>
:
bug acknowledged by developer.
(Fri, 26 Oct 2018 11:59:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 33097-done <at> debbugs.gnu.org (full text, mbox):
On 10/23/18 2:18 AM, Assaf Gordon wrote:
> On 21/10/18 05:06 PM, Bernhard Voelker wrote:
>
>> The 3rd patch adds support for 'test -N FILE' as in bash.
>> Please check (on various platforms / file systems if possible).
>
> "test-N.sh" passes on FreeBSD,OpenBSD,NetBSD (with their respective
> default file systems) and on cygwin 64bit over ntfs.
>
> Also passes on ext4 inside a directory with "chattr +A" (disabled access time).
Many thanks for the tests. It passes on SLES12 as well.
Pushed with the change in 'test-N.sh' to +/-2 days for the vfat case.
Marking this as done.
Have a nice day,
Berny
Forcibly Merged 15278 33097.
Request was from
Assaf Gordon <assafgordon <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 28 Oct 2018 08:09:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 25 Nov 2018 12:24:11 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 266 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.