coreutils: output expected error for unrecognized options#9869
Merged
sylvestre merged 3 commits intouutils:mainfrom Feb 4, 2026
Merged
coreutils: output expected error for unrecognized options#9869sylvestre merged 3 commits intouutils:mainfrom
sylvestre merged 3 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
dd4938b to
155a215
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
sylvestre
reviewed
Dec 30, 2025
| /// Prints an "unrecognized option" error and exits | ||
| pub fn unrecognized_option(binary_name: &str, option: &OsStr) -> ! { | ||
| eprintln!( | ||
| "{}: unrecognized option '{}'", |
Contributor
|
could you please add a test? thanks |
Collaborator
Author
|
Adding integration tests and adding translate is two pr's on their own I think because this doesn't have integration tests yet and doesn't have a translation utility, theres a few details about adding both of those because this utility is unique. Going to work on both of those in seperate PR's before updating this one |
Contributor
|
Do you think that we should stop Line 174 in e7f8247 |
This file contains hidden or 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
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.
The coreutils multicall binary doesn't use clap for argument parsing - it manually handles a few known options (--list, --version, --help) and treats everything else as a utility name.
When given an unrecognized option like
--unknownor-/, it was outputting:This was causing the
usage_vs_getopt.shGNU test to fail because it expects the standard error format:This PR adds detection for option-like arguments (starting with
-) and outputs the proper error message.