diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 821def70d..1ba5ee0b5 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1198,12 +1198,14 @@ pub fn uu_app() -> App<'static, 'static> { options::check::QUIET, options::check::DIAGNOSE_FIRST, ]) + .conflicts_with(options::OUTPUT) .help("check for sorted input; do not sort"), ) .arg( Arg::with_name(options::check::CHECK_SILENT) .short("C") .long(options::check::CHECK_SILENT) + .conflicts_with(options::OUTPUT) .help("exit successfully if the given file is already sorted, and exit with status 1 otherwise."), ) .arg( diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 2c99c1536..1d41ddac5 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -937,3 +937,17 @@ fn test_sigpipe_panic() { Ok(String::new()) ); } + +#[test] +fn test_conflict_check_out() { + let check_flags = ["-c=silent", "-c=quiet", "-c=diagnose-first", "-c", "-C"]; + for check_flag in &check_flags { + new_ucmd!() + .arg(check_flag) + .arg("-o=/dev/null") + .fails() + .stderr_contains( + "error: The argument '--output ' cannot be used with '--check", + ); + } +}