Skip to content

coreutils date -ud '-2 weeks' produces error: unexpected argument '-2' found #7515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
julian-klode opened this issue Mar 20, 2025 · 1 comment · Fixed by #7548
Closed

coreutils date -ud '-2 weeks' produces error: unexpected argument '-2' found #7515

julian-klode opened this issue Mar 20, 2025 · 1 comment · Fixed by #7548
Labels

Comments

@julian-klode
Copy link

From the apt test suite:

jak@jak-t14-g3 ~/P/D/apt (solver3) [1]> ~/.cargo/bin/coreutils date -ud '-2 weeks'
error: unexpected argument '-2' found

  tip: to pass '-2' as a value, use '-- -2'

Usage: /home/jak/.cargo/bin/coreutils date [OPTION]... [+FORMAT]...
       /home/jak/.cargo/bin/coreutils date [OPTION]... [MMDDhhmm[[CC]YY][.ss]]

For more information, try '--help'.
jak@jak-t14-g3 ~/P/D/apt (solver3) [1]> date.coreutils -ud '-2 weeks'
Do 6. Mär 20:31:42 UTC 2025

This is similar to uutils/parse_datetime#127 but at a different level, seems command-line parser is confused that the option value starts with a dash?

These seem to be the only blockers for the apt test suite; there may be more lurking in date and touch, but I had to replace the two due to these 2 bugs, so I haven't found out.

@sylvestre sylvestre added the good first issue For newcomers! label Mar 22, 2025
lewisboon added a commit to lewisboon/coreutils that referenced this issue Mar 23, 2025
Issue uutils#7515
Clap needs to be specifically configured to allow values
with a leading hyphen
@lewisboon
Copy link
Contributor

I saw the good-first-issue label, so I thought I'd give it a go.

The clap argument definition needs to explicitly allow leading hyphens with allow_hyphen_values(true).

lewisboon added a commit to lewisboon/coreutils that referenced this issue Mar 24, 2025
Issue uutils#7515
Clap needs to be specifically configured to allow values
with a leading hyphen.
sylvestre pushed a commit to sylvestre/coreutils that referenced this issue Mar 26, 2025
Issue uutils#7515
Clap needs to be specifically configured to allow values
with a leading hyphen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants