提交 7db1689c 编写于 作者: J Jeff Cody 提交者: Kevin Wolf

block: fix qemu-img --help invocation

This fixes a bug introduced in commit ac1307ab, that caused the
'--help' option to not be recognized as a valid command, and not
print any help.
Signed-off-by: NJeff Cody <jcody@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 e2da502c
......@@ -2789,6 +2789,12 @@ int main(int argc, char **argv)
{
const img_cmd_t *cmd;
const char *cmdname;
int c;
int option_index = 0;
static const struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
#ifdef CONFIG_POSIX
signal(SIGPIPE, SIG_IGN);
......@@ -2803,15 +2809,20 @@ int main(int argc, char **argv)
error_exit("Not enough arguments");
}
cmdname = argv[1];
argc--; argv++;
/* find the command */
for(cmd = img_cmds; cmd->name != NULL; cmd++) {
if (!strcmp(cmdname, cmd->name)) {
return cmd->handler(argc, argv);
return cmd->handler(argc - 1, argv + 1);
}
}
c = getopt_long(argc, argv, "h", long_options, &option_index);
if (c == 'h') {
help();
}
/* not found */
error_exit("Command not found: %s", cmdname);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册