From a920464952df36e6c1797bc5dccf29f2976edf83 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 11 Oct 2023 12:13:22 -0400 Subject: [PATCH] split: undocumented options aliases + help fix --- src/uu/split/src/split.rs | 4 +++- tests/by-util/test_split.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index bfd595e4f..020ada93b 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -311,6 +311,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(OPT_NUMERIC_SUFFIXES) .long(OPT_NUMERIC_SUFFIXES) + .alias("numeric") .require_equals(true) .default_missing_value("0") .num_args(0..=1) @@ -338,6 +339,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(OPT_HEX_SUFFIXES) .long(OPT_HEX_SUFFIXES) + .alias("hex") .default_missing_value("0") .require_equals(true) .num_args(0..=1) @@ -372,7 +374,7 @@ pub fn uu_app() -> Command { .allow_hyphen_values(true) .value_name("SEP") .action(ArgAction::Append) - .help("use SEP instead of newline as the record separator; '\0' (zero) specifies the NUL character"), + .help("use SEP instead of newline as the record separator; '\\0' (zero) specifies the NUL character"), ) .arg( Arg::new(OPT_IO) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index ce80844cf..113c0fb87 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -1192,6 +1192,19 @@ fn test_numeric_suffix() { assert_eq!(at.read("x12"), ""); } +#[test] +fn test_numeric_suffix_alias() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-n", "4", "--numeric=9", "threebytes.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x09"), "a"); + assert_eq!(at.read("x10"), "b"); + assert_eq!(at.read("x11"), "c"); + assert_eq!(at.read("x12"), ""); +} + #[test] fn test_hex_suffix() { let (at, mut ucmd) = at_and_ucmd!(); @@ -1205,6 +1218,19 @@ fn test_hex_suffix() { assert_eq!(at.read("x0c"), ""); } +#[test] +fn test_hex_suffix_alias() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-n", "4", "--hex=9", "threebytes.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x09"), "a"); + assert_eq!(at.read("x0a"), "b"); + assert_eq!(at.read("x0b"), "c"); + assert_eq!(at.read("x0c"), ""); +} + #[test] fn test_numeric_suffix_no_equal() { new_ucmd!()