Fix zpool subcommands error message with some unsupported options

Both 'detach' and 'online' zpool subcommands, when provided with an
unsupported option, forget to print it in the error message:

   # zpool online -t rpool vda3
   invalid option ''
   usage:
      online [-e] <pool> <device> ...

This changes fixes the error message in order to include the actual
option that is not supported.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #9270
This commit is contained in:
loli10K 2019-09-04 22:36:25 +02:00 committed by Brian Behlendorf
parent a49dbbbe06
commit d02186ee2b
1 changed files with 2 additions and 4 deletions

View File

@ -6111,9 +6111,8 @@ zpool_do_detach(int argc, char **argv)
int ret; int ret;
/* check options */ /* check options */
while ((c = getopt(argc, argv, "f")) != -1) { while ((c = getopt(argc, argv, "")) != -1) {
switch (c) { switch (c) {
case 'f':
case '?': case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"), (void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt); optopt);
@ -6342,12 +6341,11 @@ zpool_do_online(int argc, char **argv)
int flags = 0; int flags = 0;
/* check options */ /* check options */
while ((c = getopt(argc, argv, "et")) != -1) { while ((c = getopt(argc, argv, "e")) != -1) {
switch (c) { switch (c) {
case 'e': case 'e':
flags |= ZFS_ONLINE_EXPAND; flags |= ZFS_ONLINE_EXPAND;
break; break;
case 't':
case '?': case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"), (void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt); optopt);