true/false: put Usage: on the first line of --help (#10279)#12402
Open
jamesarch wants to merge 1 commit into
Open
true/false: put Usage: on the first line of --help (#10279)#12402jamesarch wants to merge 1 commit into
Usage: on the first line of --help (#10279)#12402jamesarch wants to merge 1 commit into
Conversation
GNU `true --help` and `false --help` both open with the `Usage:` line, as
documented at the launchpad bug linked in the issue:
$ LANG=C /usr/bin/false --help | head -1
Usage: /usr/bin/false [ignored command line arguments]
uutils put the about text first, so the first line of --help was
"Returns false, an unsuccessful exit status." instead. Tools that grep
the first line for the synopsis broke.
Fix: add `uucore::localized_help_template_usage_first` (a GNU-style
ordering variant of the existing `localized_help_template`) and use it
from `true` and `false`. The new helper keeps the localized "Usage:"
label and the bold+underline styling, but emits it before the about
block instead of after.
Other utilities continue to use the existing template — this PR only
affects `true` and `false` so we don't risk breaking snapshot tests
elsewhere.
Tests: `test_help_starts_with_usage` added for both utilities,
asserting the first line of `--help` starts with `Usage:`.
Closes uutils#10279.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1df7b3a to
9fde1c2
Compare
|
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.
Closes #10279.
Problem
GNU
true --helpandfalse --helpstart with theUsage:line:uutils put the about text first, so the first line was
Returns false, an unsuccessful exit status.instead. Config tools and packaging scripts thatgrepthe synopsis from the first line broke. Reported in the Ubuntulaunchpad bug linked from the issue.
Fix
uucore::localized_help_template_usage_first, a GNU-style orderingvariant of the existing
localized_help_template. Keeps the localizedUsage:label and the bold + underline styling, but emits it before theabout block.
trueandfalseto use the new template.Other utilities continue to use the existing template — this PR is
intentionally narrow so it doesn't churn snapshot tests elsewhere. If
maintainers want to roll the GNU-style ordering out broadly later, the
helper is already in place.
Tests
test_help_starts_with_usageadded for bothtrueandfalse,asserting the first line of
--helpstarts withUsage:.🤖 Generated with Claude Code