Skip to content

join, od: report a hyphen-leading value instead of rejecting it - #14257

Open
arbelonson-source wants to merge 1 commit into
uutils:mainfrom
arbelonson-source:fix/join-od-hyphen-values
Open

join, od: report a hyphen-leading value instead of rejecting it#14257
arbelonson-source wants to merge 1 commit into
uutils:mainfrom
arbelonson-source:fix/join-od-hyphen-values

Conversation

@arbelonson-source

Copy link
Copy Markdown

GNU hands the argument after an option to that option even when it begins with a hyphen, and then reports it as invalid. join and od refused it as an unknown option instead.

Command GNU uutils before
join -1 -1 a b join: invalid field number: '-1' error: a value is required for '-1 <FIELD>' but none was supplied
join -j -1 a b join: invalid field number: '-1' same clap error
od -N -1 a od: invalid -N argument '-1' error: unexpected argument '-1' found
od -j -1 a od: invalid -j argument '-1' error: unexpected argument '-1' found

The validation that produces GNU's exact wording is already present in both — join -1 abc and od -N abc match GNU byte for byte today. The hyphen-leading value simply never reached it, so this just lets it through with allow_hyphen_values; the existing code then produces the right message unchanged.

Found by differential testing against GNU coreutils 9.11. Follows the same idea as #14256, but those were options where GNU succeeds; these are ones where both fail and only the diagnostic differs, so they are kept separate.

Testing

One regression test per utility, each covering every affected option (-1, -2, -j for join; -N, -j for od). Verified they catch the bug by reverting the two source files alone — both fail, then pass with them restored.

  • cargo test --features "join,od" --no-default-features: 116 passed, 0 failed (114 pre-existing, 2 new)
  • cargo fmt --check and cargo clippy -p uu_join -p uu_od --all-targets: clean
  • 10-case differential check covering the fixed forms plus ordinary ones (od -N 4, od -j 1, join -1 1 -2 1, join -1 abc) as regression cover: all 10 match GNU exactly

Disclosure

Prepared with AI assistance (Claude Code), per the AI policy in CONTRIBUTING.md. On the GPL point raised there: expected behavior was established by running the installed GNU binaries as a black box and recording their output. I did not read GNU coreutils source. All testing above was run locally.

GNU hands the argument after an option to that option even when it
starts with a hyphen, and then reports it as invalid:

    $ join -1 -1 a b
    join: invalid field number: '-1'
    $ od -N -1 a
    od: invalid -N argument '-1'

Both refused it as an unknown option instead. The validation that
produces those exact messages is already there — `join -1 abc` and
`od -N abc` match GNU today — so the value simply never reached it.
Let it through with allow_hyphen_values.
@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 152.18 MB (+1004 KB, +0.65%)

Significant per-binary changes:
  comm     1.12 MB ->    2.33 MB  (+1.21 MB, +107.29%)

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.

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.

1 participant