Skip to content

ls: Use case-insensitive comparison for filenames#2999

Closed
hbina wants to merge 1 commit intouutils:mainfrom
hbina:hbina-ls-sort-using-lowercase
Closed

ls: Use case-insensitive comparison for filenames#2999
hbina wants to merge 1 commit intouutils:mainfrom
hbina:hbina-ls-sort-using-lowercase

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
Collaborator

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
Collaborator

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