From 3e6187269e24a5222f456494bc70582d96d2ee0d Mon Sep 17 00:00:00 2001 From: allaboutevemirolive Date: Wed, 20 Dec 2023 23:30:46 +0200 Subject: [PATCH 1/2] fix duplicate flags --- src/uu/expand/src/expand.rs | 1 + tests/by-util/test_expand.rs | 14 ++++++++++++++ tests/fixtures/expand/alice_in_wonderland.txt | 5 +++++ 3 files changed, 20 insertions(+) create mode 100644 tests/fixtures/expand/alice_in_wonderland.txt diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index 99b9d6b81..eb9766eb4 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -275,6 +275,7 @@ pub fn uu_app() -> Command { .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .args_override_self(true) .arg( Arg::new(options::INITIAL) .long(options::INITIAL) diff --git a/tests/by-util/test_expand.rs b/tests/by-util/test_expand.rs index f6802358c..a1173c496 100644 --- a/tests/by-util/test_expand.rs +++ b/tests/by-util/test_expand.rs @@ -392,3 +392,17 @@ fn test_comma_with_plus_4() { // 01234567890 .stdout_is("a b c"); } + +#[test] +fn test_args_override() { + new_ucmd!() + .args(&["-i", "-i", "alice_in_wonderland.txt"]) + .run() + .stdout_is( + "Alice was beginning to get very tired of sitting by\n\ + her sister on the bank, and of having nothing to do: once or twice\n\ + she had peeped into the book her sister was reading, but it had no\n\ + pictures or conversations in it, \"and what is the use of a book,\"\n\ + thought Alice \"without pictures or conversation?\"\n", + ); +} diff --git a/tests/fixtures/expand/alice_in_wonderland.txt b/tests/fixtures/expand/alice_in_wonderland.txt new file mode 100644 index 000000000..a95562a1c --- /dev/null +++ b/tests/fixtures/expand/alice_in_wonderland.txt @@ -0,0 +1,5 @@ +Alice was beginning to get very tired of sitting by +her sister on the bank, and of having nothing to do: once or twice +she had peeped into the book her sister was reading, but it had no +pictures or conversations in it, "and what is the use of a book," +thought Alice "without pictures or conversation?" From f874788b2c4900ce52f052b2ed6cf3a6e9acecb0 Mon Sep 17 00:00:00 2001 From: allaboutevemirolive Date: Thu, 21 Dec 2023 10:48:58 +0200 Subject: [PATCH 2/2] Use better testcase --- tests/by-util/test_expand.rs | 15 +++++++++------ tests/fixtures/expand/alice_in_wonderland.txt | 5 ----- 2 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 tests/fixtures/expand/alice_in_wonderland.txt diff --git a/tests/by-util/test_expand.rs b/tests/by-util/test_expand.rs index a1173c496..1e26b3273 100644 --- a/tests/by-util/test_expand.rs +++ b/tests/by-util/test_expand.rs @@ -396,13 +396,16 @@ fn test_comma_with_plus_4() { #[test] fn test_args_override() { new_ucmd!() - .args(&["-i", "-i", "alice_in_wonderland.txt"]) + .args(&["-i", "-i", "with-trailing-tab.txt"]) .run() .stdout_is( - "Alice was beginning to get very tired of sitting by\n\ - her sister on the bank, and of having nothing to do: once or twice\n\ - she had peeped into the book her sister was reading, but it had no\n\ - pictures or conversations in it, \"and what is the use of a book,\"\n\ - thought Alice \"without pictures or conversation?\"\n", + "// !note: file contains significant whitespace +// * indentation uses characters +int main() { + // * next line has both a leading & trailing tab + // with tabs=> + return 0; +} +", ); } diff --git a/tests/fixtures/expand/alice_in_wonderland.txt b/tests/fixtures/expand/alice_in_wonderland.txt deleted file mode 100644 index a95562a1c..000000000 --- a/tests/fixtures/expand/alice_in_wonderland.txt +++ /dev/null @@ -1,5 +0,0 @@ -Alice was beginning to get very tired of sitting by -her sister on the bank, and of having nothing to do: once or twice -she had peeped into the book her sister was reading, but it had no -pictures or conversations in it, "and what is the use of a book," -thought Alice "without pictures or conversation?"