From 73c4bc8bc233dfa69a12c11ef78da3f328a558f2 Mon Sep 17 00:00:00 2001 From: cerdelen Date: Fri, 13 Feb 2026 16:32:55 +0100 Subject: [PATCH] date: Fix format optional argument to capture all following parameters --- src/uu/date/src/date.rs | 2 +- tests/by-util/test_date.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 13c42ec74cc..2a22ee50a75 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -624,7 +624,7 @@ pub fn uu_app() -> Command { .help(translate!("date-help-universal")) .action(ArgAction::SetTrue), ) - .arg(Arg::new(OPT_FORMAT).num_args(0..).trailing_var_arg(true)) + .arg(Arg::new(OPT_FORMAT).num_args(0..)) } fn format_date_with_locale_aware_months( diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index 134a63843cd..bddbbaf78f3 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -51,6 +51,15 @@ fn test_invalid_short_option() { .stderr_contains("unexpected argument '-w'"); } +#[test] +fn test_format_option_not_to_capture_other_valid_arguments() { + new_ucmd!() + .arg("+%Y%m%d%H%M%S") + .arg("--date") + .arg("@1770996496") + .succeeds(); +} + #[test] fn test_single_dash_as_date() { new_ucmd!()