diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index e96d2de6f..64bbf65a4 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -276,10 +276,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } }; - if ["bsd", "crc", "sysv"].contains(&algo_name) && check { - return Err(ChecksumError::AlgorithmNotSupportedWithCheck.into()); - } - let input_length = matches.get_one::(options::LENGTH); let length = match input_length { @@ -293,6 +289,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { None => None, }; + if ["bsd", "crc", "sysv"].contains(&algo_name) && check { + return Err(ChecksumError::AlgorithmNotSupportedWithCheck.into()); + } + if check { let text_flag = matches.get_flag(options::TEXT); let binary_flag = matches.get_flag(options::BINARY); diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs index 2efc78b96..c213c4a82 100644 --- a/tests/by-util/test_cksum.rs +++ b/tests/by-util/test_cksum.rs @@ -352,6 +352,18 @@ fn test_length_not_supported() { .no_stdout() .stderr_contains("--length is only supported with --algorithm=blake2b") .code_is(1); + + new_ucmd!() + .arg("-l") + .arg("158") + .arg("-c") + .arg("-a") + .arg("crc") + .arg("/tmp/xxx") + .fails() + .no_stdout() + .stderr_contains("--length is only supported with --algorithm=blake2b") + .code_is(1); } #[test]