Repository navigation
sort: report an invalid --parallel value as GNU does - #15184
Merged
Merged
Conversation
Contributor
|
We don't need to match errorr message with GNU. We can patch stderr of GnuTests if needed. |
sylvestre
reviewed
Oct 8, 2026
sylvestre
reviewed
Oct 8, 2026
Contributor
Author
|
@oech3 sort.pl checks these two messages verbatim ( |
The value was parsed by clap as a number from 1 up, so a bad one came out as "invalid value '0' for '--parallel <NUM_THREADS>': 0 is not in 1..18446744073709551615". GNU says "number in parallel must be nonzero", "invalid --parallel argument 'x'" and "invalid suffix in --parallel argument '1x'", and accepts a leading '+'. Parse the value here, with the messages sort already has for its other numeric options, and exit with status 2 as GNU does.
The parse sat inside the cfg(not(wasi)) block, so on wasi a bad value was silently accepted and parse_parallel was dead code there. Also test the empty value, and every value given as a separate argument, which is how sort.pl passes it.
sort exits before reading it, and writing to it then fails on some targets.
NdekoCode
force-pushed
the
sort-parallel-diagnostics
branch
from
October 20, 2026 19:34
1483ceb to
06b2b1e
Compare
Contributor
Author
|
@oech3, @sylvestre rebased on main. The invalid cases no longer pipe input: sort exits before reading it, and the write failed on some targets. |
Contributor
|
Thanks for your PR |
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.
The value of
--parallelwas parsed by clap as a number from 1 up, so a bad one came out asinvalid value '0' for '--parallel <NUM_THREADS>': 0 is not in 1..18446744073709551615. GNU 9.12 saysnumber in parallel must be nonzero,invalid --parallel argument 'x'(also for-1and an empty value) andinvalid suffix in --parallel argument '1x', with exit status 2, and accepts a leading+.sort now parses the value itself, with the
invalid --X argument,invalid suffixandtoo largemessages it already has for its other numeric options. A value that does not fit in 64 bits gets--parallel argument '…' too large, where GNU fails on the allocation withmemory exhausted. Checked against GNU 9.12; the sort suite passes. Part of whatsort/sort.plfrom #14705 checks.Closes #15183.