Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ls sorting of hidden files/directories not as in gnu ls #4963

Closed
alexkunde opened this issue Jun 9, 2023 · 4 comments
Closed

ls sorting of hidden files/directories not as in gnu ls #4963

alexkunde opened this issue Jun 9, 2023 · 4 comments
Labels

Comments

@alexkunde
Copy link
Contributor

Hi, while investigating something else it became apperant that uutils/coreutils does not sort be default like gnu ls does.
Gnu seems to strip the leading dot and sort elements afterwards. Please see below:
(tested with 0.0.19 and latest gnu build)

mkdir .hidden-test
touch .zzz
mkdir test1
touch test2

# ubuntu provided ls
alex@alex-amd64-ubuntu:~/github/test3$ ls -al
total 16
drwxrwxr-x 4 alex alex 4096 Jun  9 08:19 .
drwxrwxr-x 9 alex alex 4096 Jun  9 08:19 ..
drwxrwxr-x 2 alex alex 4096 Jun  9 08:19 .hidden-test
drwxrwxr-x 2 alex alex 4096 Jun  9 08:19 test1
-rw-rw-r-- 1 alex alex    0 Jun  9 08:19 test2
-rw-rw-r-- 1 alex alex    0 Jun  9 08:19 .zzz

# gnu compile from source
alex@alex-amd64-ubuntu:~/github/test3$ /home/alex/github/gnu/src/ls -al
total 16
drwxrwxr-x 4 alex alex 4096 Jun  9 08:19 .
drwxrwxr-x 9 alex alex 4096 Jun  9 08:19 ..
drwxrwxr-x 2 alex alex 4096 Jun  9 08:19 .hidden-test
drwxrwxr-x 2 alex alex 4096 Jun  9 08:19 test1
-rw-rw-r-- 1 alex alex    0 Jun  9 08:19 test2
-rw-rw-r-- 1 alex alex    0 Jun  9 08:19 .zzz

# coreutils
alex@alex-amd64-ubuntu:~/github/test3$ /home/alex/github/coreutils/target/debug/ls -al
total 16
drwxrwxr-x 4 alex alex 4096 Jun  9 08:19 .
drwxrwxr-x 9 alex alex 4096 Jun  9 08:19 ..
drwxrwxr-x 2 alex alex 4096 Jun  9 08:19 .hidden-test
-rw-rw-r-- 1 alex alex    0 Jun  9 08:19 .zzz
drwxrwxr-x 2 alex alex 4096 Jun  9 08:19 test1
-rw-rw-r-- 1 alex alex    0 Jun  9 08:19 test2
@tertsdiepraam
Copy link
Member

True! But this is intentional. This was a big rabbit hole I dove into about 2 years ago. The reason for this GNU behaviour is locale. In the C locale, the sorting behaves like what we do. We don't currently have support for locale-based sorting, so we're sticking with that for now (until we do get around to locale-based sorting).

See also:

@alexkunde
Copy link
Contributor Author

Hi @tertsdiepraam. Thanks for the quick answer, I saw it's also mentioned in #1872, its just that the bulletpoint under sorting doesnt really speak to someone if you are not into the topic. Maybe an addition like "this also leads to sorting of .files/folders in a different order" can help us (me and other rookies).

@tertsdiepraam
Copy link
Member

Good idea! I've made the explanation a bit longer. Let me know whether it's clearer now :)

@alexkunde
Copy link
Contributor Author

Yes it is perfect, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants