mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-03 17:47:44 +03:00
Fix long arg processing.
This commit is contained in:
parent
8de750c6aa
commit
7028ad4ec0
14
tools/lvm.c
14
tools/lvm.c
@ -360,9 +360,7 @@ void usage(const char *name)
|
||||
* is no short argument then the index of the
|
||||
* argument in the the_args array is set as the
|
||||
* long opt value. Yuck. Of course this means we
|
||||
* can't have more than 'a' long arguments. Since
|
||||
* we have only 1 ATM (--version) I think we can
|
||||
* live with this restriction.
|
||||
* can't have more than 'a' long arguments.
|
||||
*/
|
||||
static void _add_getopt_arg(int arg, char **ptr, struct option **o)
|
||||
{
|
||||
@ -379,7 +377,10 @@ static void _add_getopt_arg(int arg, char **ptr, struct option **o)
|
||||
(*o)->name = a->long_arg + 2;
|
||||
(*o)->has_arg = a->fn ? 1 : 0;
|
||||
(*o)->flag = NULL;
|
||||
(*o)->val = arg;
|
||||
if (a->short_arg)
|
||||
(*o)->val = a->short_arg;
|
||||
else
|
||||
(*o)->val = arg;
|
||||
(*o)++;
|
||||
}
|
||||
}
|
||||
@ -434,6 +435,9 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
|
||||
optind = 0;
|
||||
while ((opt = getopt_long(*argc, *argv, str, opts, NULL)) >= 0) {
|
||||
|
||||
if (opt == '?')
|
||||
return 0;
|
||||
|
||||
a = _find_arg(cmd->command, opt);
|
||||
|
||||
if (!a) {
|
||||
@ -1146,5 +1150,7 @@ int main(int argc, char **argv)
|
||||
|
||||
out:
|
||||
_fin(cmd);
|
||||
if (ret == ECMD_PROCESSED)
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user