Skip to content
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: treat -e as a flag, not as a multi-value arg #5989

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

BenWiederhake
Copy link
Collaborator

This PR implements and tests support for the weird permitted argument order of shuf, especially for invocations like shuf -ez firstarg secondarg, where the z shall not be interpreted as a value to -e.

This moves us closer to passing the GNU testsuite.

Related:

This PR sadly slightly degrades the quality of the error message in one case:

Before:

$ cargo run -- a b
error: unexpected argument 'b' found

Usage: /path/to/target/debug/shuf [OPTION]... [FILE]
       /path/to/target/debug/shuf -e [OPTION]... [ARG]...
       /path/to/target/debug/shuf -i LO-HI [OPTION]...

For more information, try '--help'.
[$? = 1]

After:

$ cargo run -- a b
/path/to/target/debug/shuf: unexpected argument 'b' found
Try '/path/to/target/debug/shuf --help' for more information.
[$? = 1]

Note that this does not affect the --help message, so I think it's good enough.

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks!

src/uu/shuf/src/shuf.rs Outdated Show resolved Hide resolved
src/uu/shuf/src/shuf.rs Outdated Show resolved Hide resolved
@BenWiederhake
Copy link
Collaborator Author

Changes since last push:

  • Rebased on newest main
  • Applied two cleanups – thanks @tertsdiepraam!

@BenWiederhake
Copy link
Collaborator Author

Changes since last push:

  • Fix two lints that aren't in pre-commit, but were caught by CI (specifically: prefer .cloned(), and drop an unnecessary .to_string())

@BenWiederhake
Copy link
Collaborator Author

Changes since last push:

  • Rebased on current main
  • Added two new tests for error inputs, specifically multiple files (test_shuf_two_input_files and test_shuf_three_input_files). Thanks @cakebaker!
  • Added a new test for a single dash as filename. (test_explicit_stdin_file)

@BenWiederhake
Copy link
Collaborator Author

Both failures seem to be flakes:

  • test_split::test_round_robin_limited_file_descriptors (split: unable to open 'xav'; aborting)
  • test_timeout::test_kill_subprocess (panicked at ''' does not contain 'xyz'')

@tertsdiepraam
Copy link
Member

Thanks! Your updates on the force pushes are great by the way. Really useful while reviewing!

@tertsdiepraam tertsdiepraam merged commit 69ea02d into uutils:main Feb 22, 2024
57 of 59 checks passed
@BenWiederhake BenWiederhake deleted the dev-shuf-echo-anywhere branch February 22, 2024 23:18
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.

3 participants