Skip to content

zpool/zfs: accept --help, -h, -? after a subcommand#18541

Open
chrislongros wants to merge 1 commit into
openzfs:masterfrom
chrislongros:fix/zpool-subcommand-help-v2
Open

zpool/zfs: accept --help, -h, -? after a subcommand#18541
chrislongros wants to merge 1 commit into
openzfs:masterfrom
chrislongros:fix/zpool-subcommand-help-v2

Conversation

@chrislongros
Copy link
Copy Markdown
Contributor

Motivation and Context

zpool <subcommand> --help (and -h, -?) prints invalid option '-' followed by the subcommand's usage line, instead of showing help. Same bug for every subcommand. First reported as issue 1 in #17603.

Description

Catch --help, -h, and -? after a subcommand, look it up in the command table, and print its short usage. Unknown subcommands fall through to the existing "unrecognized command" error.

How Has This Been Tested?

zpool scrub|checkpoint|create|status|attach|list --help|-h|-? on:

  • Arch Linux 6.19.10 — prints the matching short usage and exits 0.
  • FreeBSD 16.0-CURRENT — same.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the OpenZFS code style requirements.
  • I have updated the documentation accordingly.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • I have run the ZFS Test Suite with this change applied.
  • All commit messages are properly formatted and contain Signed-off-by.

Comment thread cmd/zpool/zpool_main.c
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label May 15, 2026
Comment thread cmd/zpool/zpool_main.c Outdated
Print the short usage instead of "invalid option".

Signed-off-by: Christos Longros <chris.longros@gmail.com>
@chrislongros chrislongros force-pushed the fix/zpool-subcommand-help-v2 branch from 62ca5fb to aeec515 Compare May 23, 2026 10:57
@chrislongros chrislongros changed the title zpool: accept --help, -h, -? after a subcommand zpool/zfs: accept --help, -h, -? after a subcommand May 23, 2026
@behlendorf
Copy link
Copy Markdown
Contributor

It looks like we a few consistent failures which will need to be looked at.

Tests with results other than PASS that are unexpected:
    FAIL cli_root/zfs_diff/zfs_diff_cliargs (expected PASS)
    FAIL cli_root/zfs_diff/zfs_diff_mangle (expected PASS)
    FAIL rsend/send_holds (expected PASS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Code Review Needed Ready for review and testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants