From 703084ee5e979270b7f3eee35bd09f99e9e5d439 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 22 Aug 2025 10:16:17 +0200 Subject: [PATCH] date: allow multiple -d, last wins --- src/uu/date/src/date.rs | 1 + tests/by-util/test_date.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 1685844d9..d533d280a 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -275,6 +275,7 @@ pub fn uu_app() -> Command { .long(OPT_DATE) .value_name("STRING") .allow_hyphen_values(true) + .overrides_with(OPT_DATE) .help(translate!("date-help-date")), ) .arg( diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index 7fc1dd364..f802b9884 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -504,6 +504,19 @@ fn test_invalid_date_string() { .stderr_contains("invalid date"); } +#[test] +fn test_multiple_dates() { + new_ucmd!() + .arg("-d") + .arg("invalid") + .arg("-d") + .arg("2000-02-02") + .arg("+%Y") + .succeeds() + .stdout_is("2000\n") + .no_stderr(); +} + #[test] fn test_date_one_digit_date() { new_ucmd!()