Repository: uutils/coreutils (language: rust)

Issue:
sort: options -C and -c should be mutually exclusive but aren't
Environment: Ubuntu 20.04, uutils `main` branch (git commit 6a5f2aa334a0ac69c6450eff4a432c3035b57353), GNU coreutils v8.30

Steps to reproduce:
```
sort -C -c
```

What happens now: uutils `sort` behaves as if just `-C` was given (returning with exit status 0 if input was sorted or 1 if input was not sorted).

What I expected to happen: GNU `sort` terminates with an error message due to incompatible options:
```
sort: options '-cC' are incompatible
```

Notes: this is causing a failure in GNU test file `tests/sort/sort.pl`.


Discussion / hints:

Fix patch:
diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs
index b9555974638..f2677e66136 100644
--- a/src/uu/sort/src/sort.rs
+++ b/src/uu/sort/src/sort.rs
@@ -1371,14 +1371,14 @@ pub fn uu_app() -> Command {
                     options::check::QUIET,
                     options::check::DIAGNOSE_FIRST,
                 ]))
-                .conflicts_with(options::OUTPUT)
+                .conflicts_with_all([options::OUTPUT, options::check::CHECK_SILENT])
                 .help("check for sorted input; do not sort"),
         )
         .arg(
             Arg::new(options::check::CHECK_SILENT)
                 .short('C')
                 .long(options::check::CHECK_SILENT)
-                .conflicts_with(options::OUTPUT)
+                .conflicts_with_all([options::OUTPUT, options::check::CHECK])
                 .help(
                     "exit successfully if the given file is already sorted, \
                 and exit with status 1 otherwise.",


Test patch:
diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs
index 9a12d3ef8c0..31889058e15 100644
--- a/tests/by-util/test_sort.rs
+++ b/tests/by-util/test_sort.rs
@@ -1324,3 +1324,8 @@ fn test_human_blocks_r_and_q() {
         .succeeds()
         .stdout_is(output);
 }
+
+#[test]
+fn test_args_check_conflict() {
+    new_ucmd!().arg("-c").arg("-C").fails();
+}