coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

ls: ls should ignore special characters when sorting

Open mtimaN opened this issue 1 year ago • 1 comments

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.

mtimaN avatar Dec 28 '23 08:12 mtimaN

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

cakebaker avatar Dec 28 '23 09:12 cakebaker