From 8ace291b3292f2f422cf9670ccd98be983f44bf3 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Tue, 6 Jul 2021 13:26:28 +0200 Subject: [PATCH] sort: make -k only take one argument per flag This makes it so that `sort -k 1 file` treats `file` as the input file and not the second key. --- src/uu/sort/src/sort.rs | 1 + tests/by-util/test_sort.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 1ba5ee0b5..55bcdb77b 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1267,6 +1267,7 @@ pub fn uu_app() -> App<'static, 'static> { .help("sort by a key") .long_help(LONG_HELP_KEYS) .multiple(true) + .number_of_values(1) .takes_value(true), ) .arg( diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 1d41ddac5..4a1cc3fa9 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -951,3 +951,11 @@ fn test_conflict_check_out() { ); } } + +#[test] +fn test_key_takes_one_arg() { + new_ucmd!() + .args(&["-k", "2.3", "keys_open_ended.txt"]) + .succeeds() + .stdout_is_fixture("keys_open_ended.expected"); +}