split: quote a zero SIZE in the invalid-number diagnostic - #14398
Open
Socialpranker wants to merge 1 commit into
Open
split: quote a zero SIZE in the invalid-number diagnostic#14398Socialpranker wants to merge 1 commit into
Socialpranker wants to merge 1 commit into
Conversation
Every other rejected SIZE is quoted, because parse_size_u64_max quotes the
value it could not parse. A SIZE that parses but is zero took a different
path and printed the value bare:
$ split --lines 0 file
split: invalid number of lines: 0 # was
split: invalid number of lines: '0' # GNU, and now
Same for --bytes and --line-bytes, and for the obsolete 'split -0' spelling.
|
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.
A SIZE that is rejected for being zero was printed bare, while every other
rejected SIZE is quoted:
Same for
--bytes 0,--line-bytes 0and the obsoletesplit -0spelling.The fix
parse_size_u64_maxquotes the value inside theParseSizeErroritreturns, so the parse-failure path was already right. The zero check
happens after that call and built its own
ParseSizeError::ParseFailurefrom the raw string, unquoted. It now quotes it the same way. Two call
sites:
get_and_parseand the obsolete-lines branch.Three existing assertions in
test_split.rspinned the unquoted form; theyare updated.
How the GNU behavior was established
By running the installed GNU coreutils 9.11 binary (Homebrew,
gsplit) asa black box over
-l/-b/-C/-nwith the values0,abc,1Y,-200and an overflowing number, diffing stderr and exit status againstuutils. I did not read GNU coreutils source.
Testing
test_split_zero_size_is_quotedintests/by-util/test_split.rscovers
--lines/--bytes/--line-byteswith the exact message andexit status 1. Mutation-checked: reverting
strategy.rsalone makes it,and the two updated tests, fail.
cargo test --features split --test tests test_split: 135 passed, 0 failed.cargo clippy -p uu_split --all-targets -- -D warnings: clean.cargo fmt --check: clean.splitinvocations in my harness: mismatches 2 -> 0.
Not in scope
split -C 0reports "invalid number of bytes" where GNU reports "invalidnumber of lines", and the obsolete
split -0spelling omits theTry 'split --help'line GNU prints. Both are separate from the quotingand left alone here.
Disclosure
Prepared with AI assistance (Claude Opus 5, via Claude Code), per the AI
policy in CONTRIBUTING.md. Every GNU behavior quoted above came from
running the installed binary, not from reading GPL source. All testing was
run locally.