diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index b7a26242b0..2db42dfc69 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -1997,7 +1997,7 @@ zfs_do_get(int argc, char **argv) zprop_get_cbdata_t cb = { 0 }; int i, c, flags = ZFS_ITER_ARGS_CAN_BE_PATHS; int types = ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK; - char *value, *fields; + char *fields; int ret = 0; int limit = 0; zprop_list_t fake_name = { 0 }; @@ -2115,37 +2115,29 @@ found2:; case 't': types = 0; flags &= ~ZFS_ITER_PROP_LISTSNAPS; - while (*optarg != '\0') { - static char *type_subopts[] = { "filesystem", - "volume", "snapshot", "snap", "bookmark", - "all", NULL }; - switch (getsubopt(&optarg, type_subopts, - &value)) { - case 0: - types |= ZFS_TYPE_FILESYSTEM; - break; - case 1: - types |= ZFS_TYPE_VOLUME; - break; - case 2: - case 3: - types |= ZFS_TYPE_SNAPSHOT; - break; - case 4: - types |= ZFS_TYPE_BOOKMARK; - break; - case 5: - types = ZFS_TYPE_DATASET | - ZFS_TYPE_BOOKMARK; - break; + for (char *tok; (tok = strsep(&optarg, ",")); ) { + static const char *const type_opts[] = { + "filesystem", "volume", + "snapshot", "snap", + "bookmark", + "all" }; + static const int type_types[] = { + ZFS_TYPE_FILESYSTEM, ZFS_TYPE_VOLUME, + ZFS_TYPE_SNAPSHOT, ZFS_TYPE_SNAPSHOT, + ZFS_TYPE_BOOKMARK, + ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK }; - default: - (void) fprintf(stderr, - gettext("invalid type '%s'\n"), - value); - usage(B_FALSE); - } + for (i = 0; i < ARRAY_SIZE(type_opts); ++i) + if (strcmp(tok, type_opts[i]) == 0) { + types |= type_types[i]; + goto found3; + } + + (void) fprintf(stderr, + gettext("invalid type '%s'\n"), tok); + usage(B_FALSE); +found3:; } break;