Skip to content
Permalink
Browse files

7742 zfs send wrong error message with invalid long opts

Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Steve Gonczi <steve.gonczi@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
  • Loading branch information...
pcd1193182 authored and ahrens committed Jan 18, 2017
1 parent 1a12e87 commit 5c653870ec5357c65dc7d975a8c34619d9da0566
Showing with 31 additions and 4 deletions.
  1. +31 −4 usr/src/cmd/zfs/zfs_main.c
@@ -3769,15 +3769,42 @@ zfs_do_send(int argc, char **argv)
flags.compress = B_TRUE;
break;
case ':':
(void) fprintf(stderr, gettext("missing argument for "
"'%c' option\n"), optopt);
/*
* If a parameter was not passed, optopt contains the
* value that would normally lead us into the
* appropriate case statement. If it's > 256, then this
* must be a longopt and we should look at argv to get
* the string. Otherwise it's just the character, so we
* should use it directly.
*/
if (optopt <= UINT8_MAX) {
(void) fprintf(stderr,
gettext("missing argument for '%c' "
"option\n"), optopt);
} else {
(void) fprintf(stderr,
gettext("missing argument for '%s' "
"option\n"), argv[optind - 1]);
}
usage(B_FALSE);
break;
case '?':
/*FALLTHROUGH*/
default:
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);
/*
* If an invalid flag was passed, optopt contains the
* character if it was a short flag, or 0 if it was a
* longopt.
*/
if (optopt != 0) {
(void) fprintf(stderr,
gettext("invalid option '%c'\n"), optopt);
} else {
(void) fprintf(stderr,
gettext("invalid option '%s'\n"),
argv[optind - 1]);

}
usage(B_FALSE);
}
}

0 comments on commit 5c65387

Please sign in to comment.
You can’t perform that action at this time.