zpool/zfs: accept --help and -? after a subcommand
Print the short usage instead of "invalid option". Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Christos Longros <chris.longros@gmail.com> Closes #18541
This commit is contained in:
@@ -9399,6 +9399,18 @@ main(int argc, char **argv)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special case '<subcommand> --help|-?'
|
||||||
|
*/
|
||||||
|
if (argc >= 3 && (strcmp(argv[2], "--help") == 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));
|
zfs_save_arguments(argc, argv, history_str, sizeof (history_str));
|
||||||
|
|
||||||
libzfs_print_on_error(g_zfs, B_TRUE);
|
libzfs_print_on_error(g_zfs, B_TRUE);
|
||||||
|
|||||||
@@ -13878,6 +13878,18 @@ main(int argc, char **argv)
|
|||||||
if (strcmp(cmdname, "help") == 0)
|
if (strcmp(cmdname, "help") == 0)
|
||||||
return (zpool_do_help(argc, argv));
|
return (zpool_do_help(argc, argv));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special case '<subcommand> --help|-?'
|
||||||
|
*/
|
||||||
|
if (argc >= 3 && (strcmp(argv[2], "--help") == 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) {
|
if ((g_zfs = libzfs_init()) == NULL) {
|
||||||
(void) fprintf(stderr, "%s\n", libzfs_error_init(errno));
|
(void) fprintf(stderr, "%s\n", libzfs_error_init(errno));
|
||||||
return (1);
|
return (1);
|
||||||
|
|||||||
Reference in New Issue
Block a user