Skip to content

Commit

Permalink
ls: bump lscolors version (#6537)
Browse files Browse the repository at this point in the history
when one suffix is specified more than once with different cases and with different styles, then ls would only do a case-sensitive matching.
  • Loading branch information
matrixhead authored Aug 19, 2024
1 parent 3cad85f commit 7887b76
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ hostname = "0.4"
indicatif = "0.17.8"
itertools = "0.13.0"
libc = "0.2.153"
lscolors = { version = "0.18.0", default-features = false, features = [
lscolors = { version = "0.19.0", default-features = false, features = [
"gnu_legacy",
] }
memchr = "2.7.2"
Expand Down
108 changes: 108 additions & 0 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4950,3 +4950,111 @@ fn test_ls_color_clear_to_eol() {
// cspell:disable-next-line
result.stdout_contains("\x1b[0m\x1b[31;42mzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.foo\x1b[0m\x1b[K");
}

#[test]
fn test_suffix_case_sensitivity() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("img1.jpg");
at.touch("IMG2.JPG");
at.touch("img3.JpG");
at.touch("file1.z");
at.touch("file2.Z");

// *.jpg is specified only once so any suffix that has .jpg should match
// without caring about the letter case
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35:*.Z=01;31")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("file1.z")
.arg("file2.Z")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35mimg1.jpg\x1b[0m\n\
\x1b[01;35mIMG2.JPG\x1b[0m\n\
\x1b[01;31mfile1.z\x1b[0m\n\
\x1b[01;31mfile2.Z\x1b[0m",
/* cSpell:enable */
);

// *.jpg is specified more than once with different cases and style, so
// case should matter here
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35:*.JPG=01;35;46")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("img3.JpG")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35mimg1.jpg\x1b[0m\n\
\x1b[01;35;46mIMG2.JPG\x1b[0m\n\
img3.JpG",
/* cSpell:enable */
);

// *.jpg is specified more than once with different cases but style is same, so
// case can ignored
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35:*.JPG=01;35")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("img3.JpG")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35mimg1.jpg\x1b[0m\n\
\x1b[01;35mIMG2.JPG\x1b[0m\n\
\x1b[01;35mimg3.JpG\x1b[0m",
/* cSpell:enable */
);

// last *.jpg gets more priority resulting in same style across
// different cases specified, so case can ignored
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35:*.jpg=01;35;46:*.JPG=01;35;46")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("img3.JpG")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35;46mimg1.jpg\x1b[0m\n\
\x1b[01;35;46mIMG2.JPG\x1b[0m\n\
\x1b[01;35;46mimg3.JpG\x1b[0m",
/* cSpell:enable */
);

// last *.jpg gets more priority resulting in different style across
// different cases specified, so case matters
let result = scene
.ucmd()
.env("LS_COLORS", "*.jpg=01;35;46:*.jpg=01;35:*.JPG=01;35;46")
.arg("-U1")
.arg("--color=always")
.arg("img1.jpg")
.arg("IMG2.JPG")
.arg("img3.JpG")
.succeeds();
result.stdout_contains(
/* cSpell:disable */
"\x1b[0m\x1b[01;35mimg1.jpg\x1b[0m\n\
\x1b[01;35;46mIMG2.JPG\x1b[0m\n\
img3.JpG",
/* cSpell:enable */
);
}

0 comments on commit 7887b76

Please sign in to comment.