diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index ba76b7f77..f6a1f2739 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -275,6 +275,7 @@ pub fn uu_app() -> Command { .long(options::FIELD) .help("replace the numbers in these input fields; see FIELDS below") .value_name("FIELDS") + .allow_hyphen_values(true) .default_value(options::FIELD_DEFAULT), ) .arg( diff --git a/tests/by-util/test_numfmt.rs b/tests/by-util/test_numfmt.rs index 821b8e70b..49de861fb 100644 --- a/tests/by-util/test_numfmt.rs +++ b/tests/by-util/test_numfmt.rs @@ -375,6 +375,14 @@ fn test_format_selected_fields() { .stdout_only("1000 2K 3000 4000 5K 6K\n"); } +#[test] +fn test_format_implied_range_and_field() { + new_ucmd!() + .args(&["--from=auto", "--field", "-2,4", "1K 2K 3K 4K 5K 6K"]) + .succeeds() + .stdout_only("1000 2000 3K 4000 5K 6K\n"); +} + #[test] fn test_should_succeed_if_selected_field_out_of_range() { new_ucmd!()