Skip to content

true/false: put Usage: on the first line of --help (#10279)#12402

Open
jamesarch wants to merge 1 commit into
uutils:mainfrom
jamesarch:fix/10279-true-false-usage
Open

true/false: put Usage: on the first line of --help (#10279)#12402
jamesarch wants to merge 1 commit into
uutils:mainfrom
jamesarch:fix/10279-true-false-usage

Conversation

@jamesarch
Copy link
Copy Markdown

Closes #10279.

Problem

GNU true --help and false --help start with the Usage: line:

$ 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 was Returns false, an unsuccessful exit status. instead. Config tools and packaging scripts that
grep the synopsis from the first line broke. Reported in the Ubuntu
launchpad bug linked from the issue.

Fix

  • Add uucore::localized_help_template_usage_first, a GNU-style ordering
    variant of the existing localized_help_template. Keeps the localized
    Usage: label and the bold + underline styling, but emits it before the
    about block.
  • Switch true and false to 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_usage added for both true and false,
    asserting the first line of --help starts with Usage:.
$ cargo test --features 'true,false' --test tests -- test_true test_false
running 14 tests
test result: ok. 14 passed; 0 failed

🤖 Generated with Claude Code

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>
@jamesarch jamesarch force-pushed the fix/10279-true-false-usage branch from 1df7b3a to 9fde1c2 Compare May 20, 2026 12:15
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/basenc/bounded-memory is now being skipped but was previously passing.
Congrats! The gnu test tests/cut/cut-huge-range is now passing!
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

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.

missing "Usage:" in true/false

1 participant