-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shuf: Fix off-by-one errors in range handling #6014
Merged
sylvestre
merged 2 commits into
uutils:main
from
BenWiederhake:dev-shuf-range-off-by-one
Mar 10, 2024
Merged
shuf: Fix off-by-one errors in range handling #6014
sylvestre
merged 2 commits into
uutils:main
from
BenWiederhake:dev-shuf-range-off-by-one
Mar 10, 2024
Conversation
This file contains 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
GNU testsuite comparison:
|
BenWiederhake
force-pushed
the
dev-shuf-range-off-by-one
branch
from
February 27, 2024 22:54
9549bae
to
5fe4ed1
Compare
Changes since last push:
|
Looks like we accidentally found a bug in Windows BFD, because it says
Yet another failed CI that has to be ignored. |
sylvestre
force-pushed
the
dev-shuf-range-off-by-one
branch
from
March 9, 2024 21:51
5fe4ed1
to
b233569
Compare
GNU testsuite comparison:
|
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.
It seems that I accidentally introduced an off-by-one error in #5980. My bad!
This PR:
RangeInclusive<usize>
, instead of passing(usize, usize)
around and hoping that we don't forget whether the range is inclusive or exclusive. (That was the bug.)shuf
is somewhat inefficient, especially when permuting a reasonably-large number range.)-n
:fn parse_head_count
defaults tostd::usize::MAX
, which is technically a bug, but has no practical impact.Sadly, it seems that GNU shuf is buggy:
I really hope we do not try to be bug-compatible. This PR results in: