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: C sort order and fix subdirectory listing #2161

Merged

Conversation

tertsdiepraam
Copy link
Member

@tertsdiepraam tertsdiepraam commented May 2, 2021

Fixes #2149

  • The sort order is reverted to a simple string compare without any preprocessing (lowercasing & ignoring leading periods) to match the C locale. This makes the uutils ls faster than GNU on my machine, but this is misleading because GNU does localization by default. The BENCHMARKING.md therefore includes a note stating that comparisons should be done with LC_ALL=C.
  • The name of the . folder is fixed and tests are added for this case.

Before

❯ target/release/coreutils ls -al test_folder/
drwxr-xr-x  3 terts terts 4096 May  1 09:16 test_folder
drwxr-xr-x 15 terts terts 4096 May  2 10:15 ..
-rw-r--r--  1 terts terts    0 Apr 30 21:23 Formula
-rw-r--r--  1 terts terts    0 May  1 09:16 formula
drwxr-xr-x  2 terts terts 4096 Apr 30 21:23 .git
-rw-r--r--  1 terts terts    0 Apr 30 21:23 Makefile
-rw-r--r--  1 terts terts    0 Apr 30 21:23 README.md

After

❯ target/release/coreutils ls -al test_folder/
drwxr-xr-x  3 terts terts 4096 May  1 09:16 .
drwxr-xr-x 15 terts terts 4096 May  2 10:15 ..
drwxr-xr-x  2 terts terts 4096 Apr 30 21:23 .git
-rw-r--r--  1 terts terts    0 Apr 30 21:23 Formula
-rw-r--r--  1 terts terts    0 Apr 30 21:23 Makefile
-rw-r--r--  1 terts terts    0 Apr 30 21:23 README.md
-rw-r--r--  1 terts terts    0 May  1 09:16 formula

@sylvestre
Copy link
Contributor

Fails on windows:


---- test_ls::test_ls_a stdout ----
current_directory_resolved: 
touch: C:\Users\RUNNER~1\AppData\Local\Temp\.tmp4rYDF8\.test-1
mkdir: C:\Users\RUNNER~1\AppData\Local\Temp\.tmp4rYDF8\some-dir
touch: C:\Users\RUNNER~1\AppData\Local\Temp\.tmp4rYDF8\some-dir\.test-2
run: D:\a\coreutils\coreutils\target\x86_64-pc-windows-gnu\debug\coreutils.exe ls
run: D:\a\coreutils\coreutils\target\x86_64-pc-windows-gnu\debug\coreutils.exe ls -a
thread 'test_ls::test_ls_a' panicked at 'Stdout does not match regex:
.  ..  .test-1  some-dir
', tests\common\util.rs:319:13


failures:
    test_ls::test_ls_a

@tertsdiepraam
Copy link
Member Author

Should be fixed now!

@sylvestre sylvestre merged commit f8ec4a5 into uutils:master May 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"ls" returns different sort order, incorrect results for subdirectory listings.
2 participants