From 268af90843ca8b047a723ca38b88c970db31007e Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 24 Feb 2024 18:23:51 +0100 Subject: [PATCH] tr: enable passing -s multiple times --- src/uu/tr/src/tr.rs | 3 ++- tests/by-util/test_tr.rs | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index ec3fc6763..df603427f 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -191,7 +191,8 @@ pub fn uu_app() -> Command { listed in the last specified SET, with a single occurrence \ of that character", ) - .action(ArgAction::SetTrue), + .action(ArgAction::SetTrue) + .overrides_with(options::SQUEEZE), ) .arg( Arg::new(options::TRUNCATE_SET1) diff --git a/tests/by-util/test_tr.rs b/tests/by-util/test_tr.rs index da55daa1c..4825fa958 100644 --- a/tests/by-util/test_tr.rs +++ b/tests/by-util/test_tr.rs @@ -182,7 +182,16 @@ fn test_squeeze() { new_ucmd!() .args(&["-s", "a-z"]) .pipe_in("aaBBcDcc") - .run() + .succeeds() + .stdout_is("aBBcDc"); +} + +#[test] +fn test_squeeze_multi() { + new_ucmd!() + .args(&["-ss", "-s", "a-z"]) + .pipe_in("aaBBcDcc") + .succeeds() .stdout_is("aBBcDc"); } @@ -191,7 +200,16 @@ fn test_squeeze_complement() { new_ucmd!() .args(&["-sc", "a-z"]) .pipe_in("aaBBcDcc") - .run() + .succeeds() + .stdout_is("aaBcDcc"); +} + +#[test] +fn test_squeeze_complement_multi() { + new_ucmd!() + .args(&["-scsc", "a-z"]) // spell-checker:disable-line + .pipe_in("aaBBcDcc") + .succeeds() .stdout_is("aaBcDcc"); }