提交 763f71e5 编写于 作者: E Eric Blake 提交者: Cole Robinson

virsh: make -h always give help

https://bugzilla.redhat.com/show_bug.cgi?id=817244 mentions that
unlike most other tools, where --help or --version prevent all
further parsing of all later options, virsh was strange in that
--version stopped parsing but --help tried to plow on to the end.
There was no rationale for this original implementation (since
2005!), so I think we can safely conform to common usage patterns.

* tools/virsh.c (main): Drop useless 'help' variable.
(cherry picked from commit 46e5d36b)
上级 180fb3b2
...@@ -19896,7 +19896,6 @@ vshAllowedEscapeChar(char c) ...@@ -19896,7 +19896,6 @@ vshAllowedEscapeChar(char c)
static bool static bool
vshParseArgv(vshControl *ctl, int argc, char **argv) vshParseArgv(vshControl *ctl, int argc, char **argv)
{ {
bool help = false;
int arg, len; int arg, len;
struct option opt[] = { struct option opt[] = {
{"debug", required_argument, NULL, 'd'}, {"debug", required_argument, NULL, 'd'},
...@@ -19923,7 +19922,8 @@ vshParseArgv(vshControl *ctl, int argc, char **argv) ...@@ -19923,7 +19922,8 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
} }
break; break;
case 'h': case 'h':
help = true; vshUsage();
exit(EXIT_SUCCESS);
break; break;
case 'q': case 'q':
ctl->quiet = true; ctl->quiet = true;
...@@ -19968,17 +19968,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv) ...@@ -19968,17 +19968,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
} }
} }
if (help) {
if (optind < argc) {
vshError(ctl, _("extra argument '%s'. See --help."), argv[optind]);
exit(EXIT_FAILURE);
}
/* list all command */
vshUsage();
exit(EXIT_SUCCESS);
}
if (argc > optind) { if (argc > optind) {
/* parse command */ /* parse command */
ctl->imode = false; ctl->imode = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册