diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 0050bf0c32d..bfe58f11d8e 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -1016,13 +1016,15 @@ pub fn uu_app() -> Command { Arg::new("check-order") .long("check-order") .help(translate!("join-help-check-order")) - .action(ArgAction::SetTrue), + .action(ArgAction::SetTrue) + .overrides_with("nocheck-order"), ) .arg( Arg::new("nocheck-order") .long("nocheck-order") .help(translate!("join-help-nocheck-order")) - .action(ArgAction::SetTrue), + .action(ArgAction::SetTrue) + .overrides_with("check-order"), ) .arg( Arg::new("header") diff --git a/tests/by-util/test_join.rs b/tests/by-util/test_join.rs index 21334bd6b67..b8952f73ffe 100644 --- a/tests/by-util/test_join.rs +++ b/tests/by-util/test_join.rs @@ -1038,3 +1038,21 @@ fn test_missing_key_is_empty_key() { .succeeds() .stdout_only("1002 bob\n"); } + +#[test] +fn test_last_of_check_order_nocheck_order_wins() { + let scene = TestScenario::new(util_name!()); + scene.fixtures.write("a.txt", "b\na\n"); + scene + .ucmd() + .args(&["--check-order", "--nocheck-order", "a.txt", "a.txt"]) + .succeeds() + .stdout_is("b\na\n"); + + // The other order: --check-order wins and the unsorted input is reported. + scene + .ucmd() + .args(&["--nocheck-order", "--check-order", "a.txt", "a.txt"]) + .fails_with_code(1) + .stderr_is("join: a.txt:2: is not sorted: a\n"); +}