ls: bump lscolors version (#6537)

when one suffix is specified more than once with different cases and with different styles, then ls would only do a case-sensitive matching.
This commit is contained in:
sreehari prasad 2024-08-19 21:37:28 +05:30 committed by GitHub
parent 3cad85f05a
commit 7887b76dab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 114 additions and 5 deletions

9
Cargo.lock generated
View file

@ -22,9 +22,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
version = "1.0.4"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
@ -1383,10 +1383,11 @@ dependencies = [
[[package]]
name = "lscolors"
version = "0.18.0"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02a5d67fc8a616f260ee9a36868547da09ac24178a4b84708cd8ea781372fbe4"
checksum = "55f5f3bc18b481c70c416920f4bb02f7df64b99dbee36d8445027042a273ab84"
dependencies = [
"aho-corasick",
"nu-ansi-term",
]

View file

@ -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"

View file

@ -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 */
);
}