uutils / uutils/coreutils

date: `iso-8601` argument format discrepancy

Open
#6,387 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - date
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

The coreutils version currently accepts more argument option-value formats than that of the GNU version:

GNU:
-I[FMT], --iso-8601[=FMT] output date/time in ISO 8601 format...
coreutils:
-I, --iso-8601 [<FMT>] output date/time in ISO 8601 format...

This means the following arguments are accepted by coreutils but not GNU:

  • date -I=seconds
  • date -I seconds
  • date --iso-8601 seconds

GNU will treat =seconds as the value in the first one, and treat seconds as the positional argument [+FORMAT] in the next two.

coreutils will also reject some that are accepted by GNU since it will take the positional argument as the argument value, e.g. date -I 05091009:

error: invalid value '05091009' for '--iso-8601 [<FMT>]'
  [possible values: date, hours, minutes, seconds, ns]

This cannot be simply fixed by setting require_equals for the clap argument, since it would also preclude the correct syntax -Iseconds. There probably are more examples of this discrepancy in coreutils (please comment below).

This is a known limitation in clap, and I have commented in this clap issue and made a fix PR.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the date command's -I/--iso-8601 argument parsing and compare the GNU examples in the issue with clap issue #3030 and PR #5489. Done means the listed argument forms behave like GNU, including preserving the valid -Iseconds syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.