mirror_zfs/cmd
George Melikov a873815b95 OpenZFS 7742 - zfs send wrong error message with invalid long opts
There are two cases:

    1. if an invalid flag is passed, and
    2. if a valid flag is not given a parameter.

In the case of (1), the flag is either short or long. For short flags,
optopt contains the character of the flag. For long, it contains zero,
and we can access the long flag using argv and optind.

In the case of (2), if the flag is short, optopt contains the character
of the flag. If the flag is long, the value in the 4th column of the
long_options table, for that flag, is returned.

We could case over all those values, or we could simply use argv and
optind again.

Note that in the case of something like `--resume`, which is also `-t`,
"t" will be returned if an argument is not provided; so the error
message will say `'t': argument not provided` or similar. This could be
fixed by making it so long and short options don't use the same
character flag, and then combining them in the switch/case statement,
but I didn't think the ugliness of the code would be worth the small
usability enhancement.

Authored by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Steve Gonczi <steve.gonczi@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>

OpenZFS-issue: https://www.illumos.org/issues/7742
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/6d69b40
Closes #5702
2017-01-31 14:41:23 -08:00
..
arc_summary Fix TypeError: unorderable types: str() > int() in arc_summary.py 2017-01-03 12:29:23 -06:00
arcstat Correct exit code for dbufstat -v and arcstat -v 2016-10-06 10:52:21 -07:00
dbufstat Correct exit code for dbufstat -v and arcstat -v 2016-10-06 10:52:21 -07:00
fsck_zfs Add /sbin/fsck.zfs helper 2013-01-09 16:54:58 -08:00
mount_zfs Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
raidz_test OpenZFS 6871 - libzpool implementation of thread_create should enforce length is 0 2017-01-24 09:13:49 -08:00
vdev_id Add extra keyword 'slot' to vdev_id.conf 2015-08-30 10:03:56 -07:00
zdb OpenZFS 7545 - zdb should disable reference tracking 2017-01-31 14:36:35 -08:00
zed Fix spelling 2017-01-03 11:31:18 -06:00
zfs OpenZFS 7742 - zfs send wrong error message with invalid long opts 2017-01-31 14:41:23 -08:00
zhack Fix zhack argument processing 2016-08-31 14:32:46 -07:00
zinject Fix spelling 2017-01-03 11:31:18 -06:00
zpios Fix spelling 2017-01-03 11:31:18 -06:00
zpool OpenZFS 6872 - zfs libraries should not allow uninitialized variables 2017-01-24 09:23:34 -08:00
zstreamdump zstreamdump needs to initialize fletcher 4 support 2016-11-29 14:47:05 -07:00
ztest OpenZFS 7280 - Allow changing global libzpool variables in zdb and ztest through command line 2017-01-31 10:13:10 -08:00
zvol_id OpenZFS 6314 - buffer overflow in dsl_dataset_name 2016-06-28 13:47:03 -07:00
Makefile.am SIMD implementation of vdev_raidz generate and reconstruct routines 2016-06-21 09:27:26 -07:00