GNU bug report logs - #70418
ls bug

Previous Next

Package: coreutils;

Reported by: Toby Kelsey <toby.kelsey <at> gmail.com>

Date: Tue, 16 Apr 2024 15:09:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

To reply to this bug, email your comments to 70418 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#70418; Package coreutils. (Tue, 16 Apr 2024 15:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Toby Kelsey <toby.kelsey <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 16 Apr 2024 15:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Toby Kelsey <toby.kelsey <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: ls bug
Date: Tue, 16 Apr 2024 16:07:59 +0100
There appears to be a bug with 'ls' when using the '-f' and '-l' options, or at least an inconsistency with the man 
page. The man page says '-f' list entries in directory order and does not mention any incompatibilities with other 
options, however I find using it with the '-l' option gives different ouputs depending on the order of options. See the 
following script log for an example:


toby <at> toby-pc:/tmp$ mkdir test
toby <at> toby-pc:/tmp$ cd test
toby <at> toby-pc:/tmp/test$ touch c b a foo bar
toby <at> toby-pc:/tmp/test$ ls -lf
.  ..  c  b  a  foo  bar
toby <at> toby-pc:/tmp/test$ ls -fl
total 0
drwxr-xr-x  2 toby toby 140 Apr 16 15:50 .
drwxrwxrwt 18 root root 560 Apr 16 15:50 ..
-rw-r--r--  1 toby toby   0 Apr 16 15:50 c
-rw-r--r--  1 toby toby   0 Apr 16 15:50 b
-rw-r--r--  1 toby toby   0 Apr 16 15:50 a
-rw-r--r--  1 toby toby   0 Apr 16 15:50 foo
-rw-r--r--  1 toby toby   0 Apr 16 15:50 bar
toby <at> toby-pc:/tmp/test$ ls -l -f
.  ..  c  b  a  foo  bar
toby <at> toby-pc:/tmp/test$ ls -f -l
total 0
drwxr-xr-x  2 toby toby 140 Apr 16 15:50 .
drwxrwxrwt 18 root root 600 Apr 16 15:57 ..
-rw-r--r--  1 toby toby   0 Apr 16 15:50 c
-rw-r--r--  1 toby toby   0 Apr 16 15:50 b
-rw-r--r--  1 toby toby   0 Apr 16 15:50 a
-rw-r--r--  1 toby toby   0 Apr 16 15:50 foo
-rw-r--r--  1 toby toby   0 Apr 16 15:50 bar
toby <at> toby-pc:/tmp/test$ type ls
ls is /usr/bin/ls

toby <at> toby-pc:/tmp/test$ ls --version
ls (GNU coreutils) 9.4

Copyright (C) 2023 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.



Written by Richard M. Stallman and David MacKenzie.


Regards,

Toby





Information forwarded to bug-coreutils <at> gnu.org:
bug#70418; Package coreutils. (Tue, 16 Apr 2024 15:54:04 GMT) Full text and rfc822 format available.

Message #8 received at 70418 <at> debbugs.gnu.org (full text, mbox):

From: Chris Elvidge <celvidge001 <at> gmail.com>
To: Toby Kelsey <toby.kelsey <at> gmail.com>, 70418 <at> debbugs.gnu.org
Subject: Re: bug#70418: ls bug
Date: Tue, 16 Apr 2024 16:53:06 +0100

On 16/04/2024 at 16:07, Toby Kelsey wrote:
> There appears to be a bug with 'ls' when using the '-f' and '-l' 
> options, or at least an inconsistency with the man page. The man page 
> says '-f' list entries in directory order and does not mention any 
> incompatibilities with other options, however I find using it with the 
> '-l' option gives different ouputs depending on the order of options. 
> See the following script log for an example:
> 
> 
It really says -f = do not sort, enable -aU. -U = do not sort

It also says -f = disable -ls --color

So -l -f = -f takes precedence, -f -l = -l takes precedence.

-- 

Chris Elvidge





Information forwarded to bug-coreutils <at> gnu.org:
bug#70418; Package coreutils. (Tue, 16 Apr 2024 21:31:02 GMT) Full text and rfc822 format available.

Message #11 received at 70418 <at> debbugs.gnu.org (full text, mbox):

From: Toby Kelsey <toby.kelsey <at> gmail.com>
To: Chris Elvidge <celvidge001 <at> gmail.com>, 70418 <at> debbugs.gnu.org
Subject: Re: bug#70418: ls bug
Date: Tue, 16 Apr 2024 22:30:04 +0100
The man page doesn't explain this format conflict, while the info page (info '(coreutils) ls invocation' or 'info ls') 
claims '-f' implies '-1' which is also incorrect: 'ls -1f' gives different output to to 'ls -f'.

I am using coreutils 9.4-3 in Manjaro and the online documentation for 9.5 
<https://www.gnu.org/software/coreutils/manual/html_node/Sorting-the-output.html> seems to to be only document 
consistent with actual 9.4 behavior ('-f'  implies '-aU' and disables '-l'), Technically then these are errors in the 
man and info pages, but I think it is misleading to have what is described as a 'sort option'  determining output 
format. If the option was described correctly in the man and info documents installed with the software that would be 
some improvement. Hopefully 9.5 fixes these bugs.

Toby

On 16/04/2024 16:53, Chris Elvidge wrote:
>
>
> On 16/04/2024 at 16:07, Toby Kelsey wrote:
>> There appears to be a bug with 'ls' when using the '-f' and '-l' options, or at least an inconsistency with the man 
>> page. The man page says '-f' list entries in directory order and does not mention any incompatibilities with other 
>> options, however I find using it with the '-l' option gives different ouputs depending on the order of options. See 
>> the following script log for an example:
>>
>>
> It really says -f = do not sort, enable -aU. -U = do not sort
>
> It also says -f = disable -ls --color
>
> So -l -f = -f takes precedence, -f -l = -l takes precedence.
>





Information forwarded to bug-coreutils <at> gnu.org:
bug#70418; Package coreutils. (Tue, 16 Apr 2024 22:19:03 GMT) Full text and rfc822 format available.

Message #14 received at 70418 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Toby Kelsey <toby.kelsey <at> gmail.com>
Cc: Chris Elvidge <celvidge001 <at> gmail.com>, 70418 <at> debbugs.gnu.org
Subject: Re: bug#70418: ls bug
Date: Tue, 16 Apr 2024 15:17:54 -0700
[Message part 1 (text/plain, inline)]
On 4/16/24 14:30, Toby Kelsey wrote:
> The man page doesn't explain this format conflict, while the info page 
> (info '(coreutils) ls invocation' or 'info ls') claims '-f' implies '-1' 
> which is also incorrect: 'ls -1f' gives different output to to 'ls -f'.

Yes, this area of GNU 'ls' a mess. Option order should not matter here.

Option order didn't matter in 7th Edition Unix, where -f overrode -l 
regardless of whether -f came before or after -l. And option order 
doesn't matter in FreeBSD, where -f and -l are orthogonal. GNU ls is an 
odd hybrid of 7th Edition and FreeBSD and messes this up.

Rather than document the hybrid mess, let's bite the bullet and fix it. 
FreeBSD behavior makes more sense, so let's do that. Proposed patch 
attached.
[0001-ls-f-now-means-a-U.patch (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#70418; Package coreutils. (Tue, 16 Apr 2024 22:55:02 GMT) Full text and rfc822 format available.

Message #17 received at 70418 <at> debbugs.gnu.org (full text, mbox):

From: Chris Elvidge <celvidge001 <at> gmail.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, Toby Kelsey <toby.kelsey <at> gmail.com>
Cc: 70418 <at> debbugs.gnu.org
Subject: Re: bug#70418: ls bug
Date: Tue, 16 Apr 2024 23:53:24 +0100
Thanks for the clarification and patch

On 16/04/2024 at 23:17, Paul Eggert wrote:
> On 4/16/24 14:30, Toby Kelsey wrote:
>> The man page doesn't explain this format conflict, while the info page 
>> (info '(coreutils) ls invocation' or 'info ls') claims '-f' implies 
>> '-1' which is also incorrect: 'ls -1f' gives different output to to 
>> 'ls -f'.
> 
> Yes, this area of GNU 'ls' a mess. Option order should not matter here.
> 
> Option order didn't matter in 7th Edition Unix, where -f overrode -l 
> regardless of whether -f came before or after -l. And option order 
> doesn't matter in FreeBSD, where -f and -l are orthogonal. GNU ls is an 
> odd hybrid of 7th Edition and FreeBSD and messes this up.
> 
> Rather than document the hybrid mess, let's bite the bullet and fix it. 
> FreeBSD behavior makes more sense, so let's do that. Proposed patch 
> attached.


-- 

Chris Elvidge




Information forwarded to bug-coreutils <at> gnu.org:
bug#70418; Package coreutils. (Wed, 17 Apr 2024 10:20:01 GMT) Full text and rfc822 format available.

Message #20 received at 70418 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, Toby Kelsey <toby.kelsey <at> gmail.com>
Cc: Chris Elvidge <celvidge001 <at> gmail.com>, 70418 <at> debbugs.gnu.org
Subject: Re: bug#70418: ls bug
Date: Wed, 17 Apr 2024 11:19:29 +0100
On 16/04/2024 23:17, Paul Eggert wrote:
> On 4/16/24 14:30, Toby Kelsey wrote:
>> The man page doesn't explain this format conflict, while the info page
>> (info '(coreutils) ls invocation' or 'info ls') claims '-f' implies '-1'
>> which is also incorrect: 'ls -1f' gives different output to to 'ls -f'.
> 
> Yes, this area of GNU 'ls' a mess. Option order should not matter here.
> 
> Option order didn't matter in 7th Edition Unix, where -f overrode -l
> regardless of whether -f came before or after -l. And option order
> doesn't matter in FreeBSD, where -f and -l are orthogonal. GNU ls is an
> odd hybrid of 7th Edition and FreeBSD and messes this up.
> 
> Rather than document the hybrid mess, let's bite the bullet and fix it.
> FreeBSD behavior makes more sense, so let's do that. Proposed patch
> attached.

+1

Related to this is the recent adjustment of usage() for -f:
https://bugs.gnu.org/67765

Patch looks good, and conforms to POSIX.

thanks!
Pádraig




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Wed, 17 Apr 2024 21:45:01 GMT) Full text and rfc822 format available.

Notification sent to Toby Kelsey <toby.kelsey <at> gmail.com>:
bug acknowledged by developer. (Wed, 17 Apr 2024 21:45:02 GMT) Full text and rfc822 format available.

Message #25 received at 70418-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Pádraig Brady <P <at> draigBrady.com>,
 Toby Kelsey <toby.kelsey <at> gmail.com>
Cc: Chris Elvidge <celvidge001 <at> gmail.com>, 70418-done <at> debbugs.gnu.org
Subject: Re: bug#70418: ls bug
Date: Wed, 17 Apr 2024 14:43:51 -0700
On 4/17/24 03:19, Pádraig Brady wrote:

> Patch looks good, and conforms to POSIX.

Thanks for the review. I installed the patch and am closing this bug report.





This bug report was last modified 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.