Skip to content

date: reject options to print and set the time together - #14781

Open
ddy314 wants to merge 1 commit into
uutils:mainfrom
ddy314:fix/date-print-set-conflict
Open

ddy314 wants to merge 1 commit into
uutils:mainfrom
ddy314:fix/date-print-set-conflict

Conversation

@ddy314

@ddy314 ddy314 commented Sep 21, 2026

Copy link
Copy Markdown

Reject --set combined with --date, --file, --reference or --resolution before parsing dates or accessing files. Test both argument orders using invalid set input so the tests cannot change the clock.

Fixes #14674.

Validation: 164 date tests passed, 7 ignored; Clippy and rustfmt passed.

AI-assisted with Codex.

Copilot AI lite review requested due to automatic review settings September 21, 2026 12:50
Comment thread src/uu/date/src/date.rs
{
return Err(UUsageError::new(1, translate!("date-error-print-and-set")));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it able to do same things by clap's confliction? Patching error message of GnuTetst is allowed if needed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: None

What changed in this PR

Rejects combining --set with date-printing options before date parsing or file access, with coverage for both argument orders.

Changes:

  • Adds early conflict validation in date.rs for --set with --date, --file, --reference, or --resolution.
  • Adds a localized error message for the invalid combination.
  • Adds tests covering all four conflicts in both option orders.
File Description
src/​uu/​date/​src/​date.rs Performs early validation of incompatible options.
src/​uu/​date/​locales/​en-US.ftl Adds the conflict error message.
tests/​by-util/​test_date.rs Tests conflict handling and argument ordering.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/df/skip-rootfs. tests/df/skip-rootfs is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/id/smack. tests/id/smack is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/mkdir/smack-root. tests/mkdir/smack-root is passing on 'main'. Maybe you have to rebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(date): mixing -d with -s accepted, gnu rejects it

3 participants