uutils / coreutils

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

ls: Tab produces `\t` instead of `TAB` and the output is not sorted correctly. #5490

Closed allaboutevemirolive closed 11 months ago

allaboutevemirolive commented 1 year ago

Steps to reproduce:

touch "a........a"
touch "a....    a"
touch "a        .....a"
touch "aaaaaaaaaaa"
touch "aaaaaaaaaaaa a"
touch "aaaaaaaaaaaaaaaaa"
touch "a    ·····b"
touch "a├─┤·····b"
touch "test....test"
touch "test         test"

ls -Cw18 | batcat -A

./coreutils ls -Cw18 | batcat -A

Sample output:

$ ls -Cw18 | batcat -A
───────┬────────────────────────────────────────────────────────────────────────────────
       │ STDIN
───────┼────────────────────────────────────────────────────────────────────────────────
   1   │ a├──┤├──┤.....a␊
   2   │ a....├──┤a␊
   3   │ a........a␊
   4   │ aaaaaaaaaaa␊
   5   │ aaaaaaaaaaaa├──┤a␊
   6   │ aaaaaaaaaaaaaaaaa␊
   7   │ a├──┤\u{b7}\u{b7}\u{b7}\u{b7}\u{b7}b␊
   8   │ a\u{251c}\u{2500}\u{2524}\u{b7}\u{b7}\u{b7}\u{b7}\u{b7}b␊
   9   │ coreutils␊
  10   │ test├──┤├──┤├──┤test␊
  11   │ test....test␊
───────┴────────────────────────────────────────────────────────────────────────────────
$ ./coreutils ls -Cw18 | batcat -A
───────┬────────────────────────────────────────────────────────────────────────────────
       │ STDIN
───────┼────────────────────────────────────────────────────────────────────────────────
   1   │ 'a'$'\t\t''.....a'␊
   2   │ 'a'$'\t''\u{b7}\u{b7}\u{b7}\u{b7}\u{b7}b'␊
   3   │ 'a....'$'\t''a'␊
   4   │ a........a␊
   5   │ aaaaaaaaaaa␊
   6   │ 'aaaaaaaaaaaa'$'\t''a'␊
   7   │ aaaaaaaaaaaaaaaaa␊
   8   │ a\u{251c}\u{2500}\u{2524}\u{b7}\u{b7}\u{b7}\u{b7}\u{b7}b␊
   9   │ coreutils␊
  10   │ 'test'$'\t\t\t''test'␊
  11   │ test....test␊
───────┴────────────────────────────────────────────────────────────────────────────────
cakebaker commented 1 year ago

The issue with sorting is that uutils doesn't yet support localization and uses the C locale (see https://github.com/uutils/coreutils/issues/3997). And so the sorting results are usually different, unless you specify LC_COLLATE=C when calling GNU ls.

RenjiSann commented 11 months ago

On my side, the issue is the same without the -Cw18 flags, which makes a smaller reproducible example. Most probably, this has to do with ls checking if stdout is a tty