Skip to content

shuf: Treat empty file as zero elements instead of one emptystring#5979

Merged
cakebaker merged 1 commit intouutils:mainfrom
BenWiederhake:dev-shuf-null-input
Feb 16, 2024
Merged

shuf: Treat empty file as zero elements instead of one emptystring#5979
cakebaker merged 1 commit intouutils:mainfrom
BenWiederhake:dev-shuf-null-input

Conversation

@BenWiederhake
Copy link
Copy Markdown
Collaborator

This PR makes shuf behave more like GNU shuf in the case of empty files (e.g. null stdin).

Old behavior:

$ true | cargo run -- shuf | hd
00000000  0a                                                |.|
00000001
$

GNU behavior:

$ true | shuf | hd
$

New behavior:

$ true | cargo run -- shuf | hd
$

Note that this also makes shuf-reservoir.sh in the GNU shuf tests happy.

I'm mostly new to uutils, so please do point out any resources that might help me. (I've already read {DEVELOPMENT,CONTRIBUTING,CODE_OF_CONDUCT}.md.)

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/shuf/shuf-reservoir is no longer failing!

@cakebaker cakebaker merged commit bfe6f0f into uutils:main Feb 16, 2024
@cakebaker
Copy link
Copy Markdown
Contributor

Thanks for your PR and congrats for making shuf-reservoir.sh pass :)

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.

2 participants