tee: match GNU's error for a bad --output-error value - #14308
Open
arbelonson-source wants to merge 1 commit into
Open
tee: match GNU's error for a bad --output-error value#14308arbelonson-source wants to merge 1 commit into
arbelonson-source wants to merge 1 commit into
Conversation
An unrecognized or ambiguous --output-error value produced clap's own
generic wording instead of GNU's ('invalid argument ... for
--output-error / Valid arguments are: / - 'warn' / ...').
Unlike the other options fixed in this series (uutils#14293, uutils#14303,
uutils#14304, uutils#14305, uutils#14306, uutils#14307), --output-error keeps its
ShortcutValueParser rather than being resolved by hand: each of its
choices carries its own description (clap's 'Possible values:' block
in --help), which only a value_parser can supply, and hand-rolling
that metadata a second time to drop the parser would only recreate
what it already provides. Instead, intercept a rejection specifically
on this argument after parsing and re-report it with GNU's wording
(checking for an exact match first, since 'warn' and 'exit' are
themselves prefixes of 'warn-nopipe' and 'exit-nopipe'); every other
clap error still goes through the shared formatter unchanged.
AI-assisted-by: Claude Opus 5, via Claude Code
Contributor
|
We tries to show error message better than GNU. So clap provided errors itself are not issue about compatibility. |
This was referenced Aug 31, 2026
This was referenced Aug 31, 2026
|
GNU testsuite comparison: |
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.
What
An unrecognized or ambiguous
--output-errorvalue produces clap'sown generic wording instead of GNU's:
Fix
Unlike the other options fixed in this same series (#14293, #14303,
#14304, #14305, #14306, #14307),
--output-errorkeeps itsShortcutValueParserrather than being resolved by hand: each of itschoices carries its own description, rendered as clap's "Possible
values:" block in
--help, e.g.:That per-choice text only a
value_parsercan supply to clap's helprenderer, so dropping the parser (as the other fixes in this series
do) would either lose that
--helpoutput or require hand-rollingthe same metadata a second time just to feed it back to clap for
display -- not worth it for one option. Instead, this intercepts a
rejection specifically on
--output-errorright after parsing andre-reports it with GNU's wording (checking for an exact match first,
since
warnandexitare themselves prefixes ofwarn-nopipeandexit-nopipe); every other clap error -- unknown flags,--help,--version, etc. -- still goes through the exact same sharedformatter as before, unchanged.
Testing
cargo test -p uu_tee/ fulltests/by-util/test_tee.rssuite: 37 passed, 0 failed.wa, betweenwarnandwarn-nopipe).--output-errorvalue (all real choices/abbreviations, invalid, ambiguous, empty) against GNU tee 9.11 underLC_ALL=C.--help/-h/--versionand unrelated errors (e.g. an unknown flag) are unaffected.cargo clippy -p uu_tee --all-targets -- -D warningsandcargo fmt --check: clean.This PR was written with AI assistance (Claude Opus 5, via Claude Code). I've tested the changes but please review the code carefully.