coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

shuf: Refuse repeating zero lines

Open BenWiederhake opened this issue 11 months ago • 7 comments

This was a GNU behavior bug:

$ LC_ALL=C shuf -er
shuf: no lines to repeat
[$? = 1]
$ cargo run shuf -er  # old, bad (unexpected success)
$ cargo run shuf -er  # new
shuf: no lines to repeat
[$? = 1]

Note that this bug already existed before #5980 and my other shuf-related PRs.

This should also fix the last testcase of the GNU shuf test.

BenWiederhake avatar Feb 25 '24 11:02 BenWiederhake

GNU testsuite comparison:

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

github-actions[bot] avatar Feb 25 '24 11:02 github-actions[bot]

Excellent Could you please add a test on our side? We don't rely on gnu's (too long) Thanks

sylvestre avatar Feb 25 '24 12:02 sylvestre

Sure thing!

EDIT: Fun fact, that revealed a bug I accidentally introduced recently. :D

BenWiederhake avatar Feb 25 '24 12:02 BenWiederhake

Changes since last push:

  • Added tests. Thanks @sylvestre!
  • Note that I did NOT fix or test the other newly-discovered bug, since that's a whole new can of worms, see upcoming PR.

BenWiederhake avatar Feb 25 '24 13:02 BenWiederhake

GNU testsuite comparison:

Congrats! The gnu test tests/shuf/shuf is no longer failing!
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Feb 25 '24 13:02 github-actions[bot]

Changes since last push:

  • Changed test_shuf_repeat_empty_range to test really only the empty range. Thanks @cakebaker!
  • Set it to #[ignore], as this test necessarily triggers the bug that will be resolved in #6014
  • The newly-found existing "GNU behavior bug" about negative ranges will also be handled in #6014.

Btw, I don't really understand what inotify-dir-recreate is about, but it seems unrelated for several reasons.

BenWiederhake avatar Feb 25 '24 15:02 BenWiederhake

GNU testsuite comparison:

Congrats! The gnu test tests/shuf/shuf is no longer failing!
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Feb 25 '24 16:02 github-actions[bot]

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

Great, thanks!

cakebaker avatar Feb 27 '24 14:02 cakebaker