uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.54k stars 1.26k forks source link

ls: ls should ignore special characters when sorting #5737

Open mtimaN opened 8 months ago

mtimaN commented 8 months ago

Setup:

$ touch a
$ touch \"b
$ touch c

GNU's ls sorts the files ignoring the leading ":

$ ls
 a  '"b'   c

uutils' ls sorts them lexicographically:

$ cargo run ls
'"b'  a  c

The discrepancy seems to arise from the fact that ASCII and UTF-8 have different collation rules.

cakebaker commented 8 months ago

The "problem" is that uutils ls currently only supports the standard C locale. And so its output corresponds to LC_COLLATE=C ls:

$ ls
 a  '"b'   c
$ LC_COLLATE=C ls
'"b'   a   c