From 4be9e7679d1127b7f0e945d8c695b248dc9ef53b Mon Sep 17 00:00:00 2001 From: Will Shuttleworth Date: Mon, 9 Jun 2025 17:35:06 -0400 Subject: [PATCH] stty: fix negated options getting rejected by clap --- src/uu/stty/src/stty.rs | 1 + tests/by-util/test_stty.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/uu/stty/src/stty.rs b/src/uu/stty/src/stty.rs index 6fb06acb8..c58408732 100644 --- a/src/uu/stty/src/stty.rs +++ b/src/uu/stty/src/stty.rs @@ -646,6 +646,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(options::SETTINGS) .action(ArgAction::Append) + .allow_hyphen_values(true) .help("settings to change"), ) } diff --git a/tests/by-util/test_stty.rs b/tests/by-util/test_stty.rs index e9e455e32..00a6a803a 100644 --- a/tests/by-util/test_stty.rs +++ b/tests/by-util/test_stty.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh +// spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh econl igpar use uutests::new_ucmd; use uutests::util::TestScenario; @@ -97,3 +97,16 @@ fn invalid_mapping() { .fails() .stderr_contains("invalid integer argument: '0400': Value too large for defined data type"); } + +#[test] +fn invalid_setting() { + new_ucmd!() + .args(&["-econl"]) + .fails() + .stderr_contains("invalid argument '-econl'"); + + new_ucmd!() + .args(&["igpar"]) + .fails() + .stderr_contains("invalid argument 'igpar'"); +}