diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 4c21c92bcd2f..3972fb11d8e2 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -9399,6 +9399,18 @@ main(int argc, char **argv) return (1); } + /* + * Special case ' --help|-h|-?' + */ + if (argc >= 3 && (strcmp(argv[2], "--help") == 0 || + strcmp(argv[2], "-h") == 0 || strcmp(argv[2], "-?") == 0)) { + int idx; + if (find_command_idx(cmdname, &idx) == 0) { + current_command = &command_table[idx]; + usage(B_FALSE); + } + } + zfs_save_arguments(argc, argv, history_str, sizeof (history_str)); libzfs_print_on_error(g_zfs, B_TRUE); diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 3ed7babc1ca9..2c15dea06e0f 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -13878,6 +13878,18 @@ main(int argc, char **argv) if (strcmp(cmdname, "help") == 0) return (zpool_do_help(argc, argv)); + /* + * Special case ' --help|-h|-?' + */ + if (argc >= 3 && (strcmp(argv[2], "--help") == 0 || + strcmp(argv[2], "-h") == 0 || strcmp(argv[2], "-?") == 0)) { + int idx; + if (find_command_idx(cmdname, &idx) == 0) { + current_command = &command_table[idx]; + usage(B_FALSE); + } + } + if ((g_zfs = libzfs_init()) == NULL) { (void) fprintf(stderr, "%s\n", libzfs_error_init(errno)); return (1);