Skip to content

"ls" returns different sort order, incorrect results for subdirectory listings. #2149

Closed

Description

In a recent commit, ls began changing the order in which results are returned.

I use ls --all --human-readable --color -l.

With GNU ls, results are returned in this order:

$ /usr/local/opt/coreutils/libexec/gnubin/ls --all --human-readable --color -l
total 8.0K
drwxr-xr-x  6 kevin staff  192 Dec  7 12:09 .
drwxr-xr-x 84 kevin staff 2.7K Apr 15 15:01 ..
drwxr-xr-x 15 kevin staff  480 Apr 30 11:02 .git
drwxr-xr-x 24 kevin staff  768 Apr 28 14:28 Formula
-rw-r--r--  1 kevin staff  136 Nov 25 13:45 Makefile
-rw-r--r--  1 kevin staff 1.7K Dec  7 12:09 README.md

With coreutils ls, results are returned with ".git" in the middle of "Formula" and "Makefile", which seems incorrect.

$ ls --all --human-readable --color -l
drwxr-xr-x  6 kevin  192 Dec  7 12:09 .
drwxr-xr-x 84 kevin 2.7K Apr 15 15:01 ..
drwxr-xr-x 24 kevin  768 Apr 28 14:28 Formula
drwxr-xr-x 15 kevin  480 Apr 30 11:02 .git
-rw-r--r--  1 kevin  136 Nov 25 13:45 Makefile
-rw-r--r--  1 kevin 1.7K Dec  7 12:09 README.md

If I call ls on a subdirectory, the top level "." is replaced with the directory name, in a way that makes me think there is a subdirectory of "Formula" named "Formula". It doesn't make sense.

$ ls --all --human-readable --color -l Formula
drwxr-xr-x 24 kevin  768 Apr 28 14:28 Formula
drwxr-xr-x  6 kevin  192 Dec  7 12:09 ..
-rw-r--r--  1 kevin  473 Nov 25 13:45 aws-vault.rb
-rw-r--r--  1 kevin  561 Apr 12 10:27 benchstat.rb
-rw-r--r--  1 kevin  928 Mar 11 22:21 bump_version.rb

Again this differs from the behavior of GNU ls:

$ /usr/local/opt/coreutils/libexec/gnubin/ls --all --human-readable --color -l Formula

total 96K
drwxr-xr-x 24 kevin staff  768 Apr 28 14:28 .
drwxr-xr-x  6 kevin staff  192 Dec  7 12:09 ..
-rw-r--r--  1 kevin staff  473 Nov 25 13:45 aws-vault.rb
-rw-r--r--  1 kevin staff  561 Apr 12 10:27 benchstat.rb
-rw-r--r--  1 kevin staff  928 Mar 11 22:21 bump_version.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions