diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 554fe8514..9268a40bb 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -436,7 +436,7 @@ where // 1. [-] () = // algo must be uppercase or b (for blake2b) // 2. [* ] - let regex_pattern = r"^\s*\\?(?P[A-Z0-9b]+)(-(?P\d+))?\s?\((?P.*)\) = (?P[a-fA-F0-9]+)$|^(?P[a-fA-F0-9]+)\s[* ](?P.*)"; + let regex_pattern = r"^\s*\\?(?P(?:[A-Z0-9]+|BLAKE2b))(?:-(?P\d+))?\s?\((?P.*)\) = (?P[a-fA-F0-9]+)$|^(?P[a-fA-F0-9]+)\s[* ](?P.*)"; let re = Regex::new(regex_pattern).unwrap(); // if cksum has several input files, it will print the result for each file diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs index 2bfe1b3b8..19ea2badd 100644 --- a/tests/by-util/test_cksum.rs +++ b/tests/by-util/test_cksum.rs @@ -1119,6 +1119,28 @@ fn test_blake2b_bits() { .stderr_contains("f: no properly formatted checksum lines found"); } +#[test] +fn test_bsd_case() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.write("f", "bSD (README.md) = 0000\n"); + + scene + .ucmd() + .arg("-c") + .arg("f") + .fails() + .stderr_contains("f: no properly formatted checksum lines found"); + at.write("f", "BsD (README.md) = 0000\n"); + + scene + .ucmd() + .arg("-c") + .arg("f") + .fails() + .stderr_contains("f: no properly formatted checksum lines found"); +} + #[ignore = "Different output"] #[test] fn test_blake2d_tested_with_sha1() {