Skip to content

Make shuf OsStr-compliant and bring newline handling in line with GNU #7463

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

Merged
merged 3 commits into from
Mar 22, 2025

Conversation

blyxxyz
Copy link
Contributor

@blyxxyz blyxxyz commented Mar 16, 2025

  • shuf now uses OS strings, so it can read from filenames that are invalid Unicode and it can shuffle arguments that are invalid Unicode. uucore now has an OsWrite trait to support this without platform-specific boilerplate.

  • shuf no longer tries to split individual command line arguments, only bulk input from a file/stdin. (This matches GNU and busybox.)

  • More values are parsed inside clap instead of manually, leading to better error messages and less code.

  • Some code has been simplified or made more idiomatic.

I plan to follow up with a PR to optimize shuf with vectored writes and mmap. (Last time I tried this I got sidetracked by a stdlib bug: rust-lang/rust#121938)

blyxxyz added 3 commits March 16, 2025 14:10
- shuf now uses OS strings, so it can read from filenames that are
  invalid Unicode and it can shuffle arguments that are invalid
  Unicode. `uucore` now has an `OsWrite` trait to support this without
  platform-specific boilerplate.

- shuf no longer tries to split individual command line arguments,
  only bulk input from a file/stdin. (This matches GNU and busybox.)

- More values are parsed inside clap instead of manually, leading to
  better error messages and less code.

- Some code has been simplified or made more idiomatic.
This removes the need for some manually duplicated code and keeps
shuf_exec() (which is generic) smaller, for less binary bloat and
better build times.
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/usage_vs_getopt (fails in this run but passes in the 'main' branch)

@sylvestre
Copy link
Contributor

as you are working on it, maybe implement #2528 ? :)

@sylvestre sylvestre merged commit eed5c81 into uutils:main Mar 22, 2025
67 checks passed
@blyxxyz blyxxyz deleted the clean-shuf branch March 22, 2025 21:37
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