From b0bbcc88115e9e1a7f8f376651f0388c442ff129 Mon Sep 17 00:00:00 2001 From: mhead Date: Thu, 4 Jul 2024 19:22:21 +0530 Subject: [PATCH 1/2] ls: gnu test case `color-ext` fix --- Cargo.lock | 3 +- Cargo.toml | 3 +- tests/by-util/test_ls.rs | 108 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f65300f000d..54b62f48413 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1384,8 +1384,7 @@ dependencies = [ [[package]] name = "lscolors" version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a5d67fc8a616f260ee9a36868547da09ac24178a4b84708cd8ea781372fbe4" +source = "git+https://github.com/matrixhead/lscolors#73fb17b72154d47f04f5b42d43f1e8fc8bc3e2fa" dependencies = [ "nu-ansi-term", ] diff --git a/Cargo.toml b/Cargo.toml index 3219d50b268..ac60dd92f6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -298,7 +298,8 @@ hostname = "0.4" indicatif = "0.17.8" itertools = "0.13.0" libc = "0.2.153" -lscolors = { version = "0.18.0", default-features = false, features = [ +# this is just for a draft pr +lscolors = { git = "https://github.com/matrixhead/lscolors", default-features = false, features = [ "gnu_legacy", ] } memchr = "2.7.2" diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 57802d7f310..b54ff8c843a 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -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 */ + ); +} From dd0348145d5c5259cfaa4b6591b69670c0ef4ba1 Mon Sep 17 00:00:00 2001 From: mhead Date: Mon, 19 Aug 2024 21:01:49 +0530 Subject: [PATCH 2/2] ls: bump lscolors version --- Cargo.lock | 10 ++++++---- Cargo.toml | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54b62f48413..deb9cc16af1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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,9 +1383,11 @@ dependencies = [ [[package]] name = "lscolors" -version = "0.18.0" -source = "git+https://github.com/matrixhead/lscolors#73fb17b72154d47f04f5b42d43f1e8fc8bc3e2fa" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55f5f3bc18b481c70c416920f4bb02f7df64b99dbee36d8445027042a273ab84" dependencies = [ + "aho-corasick", "nu-ansi-term", ] diff --git a/Cargo.toml b/Cargo.toml index ac60dd92f6a..719388c3af5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -298,8 +298,7 @@ hostname = "0.4" indicatif = "0.17.8" itertools = "0.13.0" libc = "0.2.153" -# this is just for a draft pr -lscolors = { git = "https://github.com/matrixhead/lscolors", default-features = false, features = [ +lscolors = { version = "0.19.0", default-features = false, features = [ "gnu_legacy", ] } memchr = "2.7.2"