From dd17f9a61cdd3507c50e765f89b83fb90cc9cc57 Mon Sep 17 00:00:00 2001 From: tommi Date: Sun, 5 Jan 2025 10:28:08 +0100 Subject: [PATCH 1/2] cksum: check ourself the flags --check and --tag and output the correct error --- src/uu/cksum/src/cksum.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 64bbf65a4..e384e51c1 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -301,8 +301,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let warn = matches.get_flag(options::WARN); let ignore_missing = matches.get_flag(options::IGNORE_MISSING); let quiet = matches.get_flag(options::QUIET); + let tag = matches.get_flag(options::TAG); - if binary_flag || text_flag { + if tag || binary_flag || text_flag { return Err(ChecksumError::BinaryTextConflict.into()); } // Determine the appropriate algorithm option to pass @@ -426,8 +427,7 @@ pub fn uu_app() -> Command { .short('c') .long(options::CHECK) .help("read hashsums from the FILEs and check them") - .action(ArgAction::SetTrue) - .conflicts_with("tag"), + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::BASE64) From 61290fd6e878f97257cdc2c2ff217284acc1b087 Mon Sep 17 00:00:00 2001 From: tommi Date: Sun, 5 Jan 2025 10:32:08 +0100 Subject: [PATCH 2/2] tests/cksum: test added to check that the --check and --tag flags are meaningless --- tests/by-util/test_cksum.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs index c213c4a82..b7c11320e 100644 --- a/tests/by-util/test_cksum.rs +++ b/tests/by-util/test_cksum.rs @@ -748,6 +748,19 @@ fn test_conflicting_options() { "cksum: the --binary and --text options are meaningless when verifying checksums", ) .code_is(1); + + scene + .ucmd() + .arg("--tag") + .arg("-c") + .arg("-a") + .arg("md5") + .fails() + .no_stdout() + .stderr_contains( + "cksum: the --binary and --text options are meaningless when verifying checksums", + ) + .code_is(1); } #[test]