Repository: uutils/coreutils (language: rust)

Issue:
cksum: `--tag` is meaningless with `--check`
(Found with fuzzer)
```
File content: /tmp/checksum_file=GVajpqCGFscY0d0ubfS5Wg==  /tmp/ghfmqwlkpt                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                            
args: ["cksum", "--tag", "-c", "-a", "md5", "/tmp/muwfducico"]                                                                                                                                                                                                                              
Running test ["cksum", "--tag", "-c", "-a", "md5", "/tmp/muwfducico"]                                                                                                                                                                                                                       
Test Type: cksum                                                                                                                                                                                                                                                                            
Input: ["--tag", "-c", "-a", "md5", "/tmp/muwfducico"]                                                                                                                                                                                                                                      
Rust stderr: the argument '--tag' cannot be used with '--check'                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                            
Usage: fuzz/target/x86_64-unknown-linux-gnu/release/fuzz_cksum [OPTIONS] [FILE]...                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                            
For more information, try '--help'.                                                                                                                                                                                                                                                         
GNU stderr: the --binary and --text options are meaningless when verifying checksums                                                                                                                                                                                                        
Try 'cksum --help' for more information.                                                                                                                                                                                                                                                    
Diff=                                                                                                                                                                                                                                                                                       
-the argument '--tag' cannot be used with '--check'                                                                                                                                                                                                                                         
-                                                                                                                                                                                                                                                                                           
-Usage: fuzz/target/x86_64-unknown-linux-gnu/release/fuzz_cksum [OPTIONS] [FILE]...                                                                                                                                                                                                         
-                                                                                                                                                                                                                                                                                           
-For more information, try '--help'.                                                                                                                                                                                                                                                        
+the --binary and --text options are meaningless when verifying checksums                                                                                                                                                                                                                   
+Try 'cksum --help' for more information.                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                            
Discrepancy detected: stderr differs                                                                                                                                                                                                                                                        
Test completed with discrepancies for cksum: ["--tag", "-c", "-a", "md5", "/tmp/muwfducico"]  
```

Here, we get clap to prevent the use of `--tag` with `--check`, rather than checking it ourselves and displaying the right message.
On this one, I think we could refine our message, to indicate that the operation is meaningless, but I feel like the GNU message is also wrong because it fails to correctly mention the faulty flag.


Discussion / hints:

Fix patch:
diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs
index 64bbf65a497..e384e51c140 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)


Test patch:
diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs
index c213c4a82d5..b7c11320e11 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]