sharkdp / lscolors

A Rust library and tool to colorize paths using LS_COLORS
Apache License 2.0
262 stars 18 forks source link

Tracking issue for incompatibilities with GNU ls #48

Open tavianator opened 2 years ago

tavianator commented 2 years ago
sharkdp commented 2 years ago

Thank you for collecting these!

alexkunde commented 1 year ago

Hi, Im working on getting the color-term gnu test for coreutils ls. And it present the following obstacle:

# rust version
~/coreutils/debug/target/ls --color=always exe
# c version
ls --color=always exe

-^[[0m^[[01;32mexe^[[0m$
+^[[1;32mexe^[[0m$

LSCOLORS with either nu-ansi-term or just ansi-term creates the additional colors as 1;xx instead of 01;xx, as well as it does not add a reset-character at the start. From what Ive tested so far, shell doesnt really care if you do any of that. At least newer shells. Maybe it was specific back in the day?

Any chance to improve here?

alexkunde commented 1 year ago

Please see https://github.com/nushell/nu-ansi-term/issues/41 it will enable a LS fix

tavianator commented 1 year ago

I just discovered a new GNU ls behaviour which even bfs gets wrong: no is not used as a fallback for fi if fi is explicitly set to 0. In every other case I tested, 0 is the same as being unset.

Screenshot_20230608_112707

alexkunde commented 1 year ago

another behavior that is ignored by lscolors crate right now, at least for nu-ansi-term, is reset styling re=xx.

matrixhead commented 4 months ago

hey, I would like to solve this issue. if you could give me some guidance on this, it would be really nice.

tavianator commented 3 months ago

I just discovered a new GNU ls behaviour which even bfs gets wrong

FTR this was fixed in bfs by https://github.com/tavianator/bfs/commit/1d1443193878ae72e54560bb21de79668cd954b9, and will be fixed here by #85.

matrixhead commented 3 months ago

Hi, I was working on GNU compatibility for uutils-ls where I encountered an issue with the suffix matching.

For example:

If we specify same suffix with two different cases and with same style.

touch img1.jpg IMG2.JPG img3.JpG
LS_COLORS="*.jpg=01;35:*.JPG=01;35" ls -U1 --color=always

This would give us the output.

^[[0m^[[01;35mimg1.jpg^[[0m
^[[01;35mIMG2.JPG^[[0m
^[[01;35mimg3.JpG^[[0m  <---------- notice it ignored the case and applied .*jpg's style to .*JpG

This would work just fine with our current version, since we always ignore the case, But if we specify the same suffix with two different cases with two different styles.

LS_COLORS="*.jpg=01;35:*.JPG=01;35;46" ls -U1 --color=always

This would give us the output.

^[[0m^[[01;35mimg1.jpg^[[0m <----------------------
^[[01;35;46mIMG2.JPG^[[0m   <---------------------- notice it honoured the cases for both the specified cases 
img3.JpG <----------- it didn't ignore the case and treated .JpG as another suffix which is not specified

So in short I suppose this is how gnu's suffix is matched, when two or more suffixes are specified in the env with different style then the matching would become case-sensitive otherwise it would ignore the cases.

matrixhead commented 3 months ago

Hi, I was working on this issue for uutils and encountered this issue,

I would like to work on this, if possible could you guys give me some guidance on this 😀