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: Use case-insensitive comparison for filenames #2999

Closed
wants to merge 1 commit into from

Conversation

hbina
Copy link
Contributor

@hbina hbina commented Jan 31, 2022

hbina@akarin:~/git/uutils$ git checkout main 
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
hbina@akarin:~/git/uutils$ diff <(ls --color=never) <(cargo run --quiet -- ls)
1,3d0
< build.rs
< Cargo.lock
< Cargo.toml
5a3,4
> Cargo.lock
> Cargo.toml
7,8d5
< docs
< examples
13a11,13
> build.rs
> docs
> examples
hbina@akarin:~/git/uutils$ git checkout hbina-ls-sort-using-lowercase 
Switched to branch 'hbina-ls-sort-using-lowercase'
hbina@akarin:~/git/uutils$ diff <(ls --color=never) <(cargo run --quiet -- ls)

Signed-off-by: Hanif Ariffin hanif.ariffin.4326@gmail.com

Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
@tertsdiepraam
Copy link
Member

Hi! So, we've done things like this before and the result was this issue: #2149

The short version is, sorting by name is dependent on locale and requires unicode collation, for which there are no good crates that I'm aware of right now. The current sorting in ls is based on the C locale. So we cannot merge this as is, but we could make a first step towards some localization. We could for instance sort case-insensitively if the locale is not C.

@tertsdiepraam
Copy link
Member

tertsdiepraam commented Jan 31, 2022

In the long term, I think we should use icu4x for all this unicode stuff, but they don't have a collator yet (unicode-org/icu4x#971). In the meantime, we could use rust_icu_ucol, which is a wrapper around the C ICU library.

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.

2 participants