From d3732e08c4bbcd518d18017e102cbe8b1e5373c1 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Sun, 27 Jun 2021 15:34:20 +0200 Subject: [PATCH] sort: disable -o with -C and -c --- src/uu/sort/src/sort.rs | 2 ++ tests/by-util/test_sort.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index fb0241945..0bad9de6b 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 3e841f630..ea98643f7 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -941,3 +941,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", + ); + } +}