Project

General

Profile

Bug #7742

zfs send wrong error message with invalid long opts

Added by Prakash Surya over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
zfs - Zettabyte File System
Start date:
2017-01-06
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

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.

History

#1

Updated by Electric Monk over 2 years ago

  • % Done changed from 0 to 100
  • Status changed from New to Closed

git commit 5c653870ec5357c65dc7d975a8c34619d9da0566

commit  5c653870ec5357c65dc7d975a8c34619d9da0566
Author: Paul Dagnelie <pcd@delphix.com>
Date:   2017-01-18T23:01:42.000Z

    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>

Also available in: Atom PDF