join, od: report a hyphen-leading value instead of rejecting it - #14257
Open
arbelonson-source wants to merge 1 commit into
Open
join, od: report a hyphen-leading value instead of rejecting it#14257arbelonson-source wants to merge 1 commit into
arbelonson-source wants to merge 1 commit into
Conversation
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.
|
Binary size comparison: |
|
GNU testsuite comparison: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GNU hands the argument after an option to that option even when it begins with a hyphen, and then reports it as invalid.
joinandodrefused it as an unknown option instead.join -1 -1 a bjoin: invalid field number: '-1'error: a value is required for '-1 <FIELD>' but none was suppliedjoin -j -1 a bjoin: invalid field number: '-1'od -N -1 aod: invalid -N argument '-1'error: unexpected argument '-1' foundod -j -1 aod: invalid -j argument '-1'error: unexpected argument '-1' foundThe validation that produces GNU's exact wording is already present in both —
join -1 abcandod -N abcmatch GNU byte for byte today. The hyphen-leading value simply never reached it, so this just lets it through withallow_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,-jfor join;-N,-jfor 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 --checkandcargo clippy -p uu_join -p uu_od --all-targets: cleanod -N 4,od -j 1,join -1 1 -2 1,join -1 abc) as regression cover: all 10 match GNU exactlyDisclosure
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.