]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: make -h always give help
authorEric Blake <eblake@redhat.com>
Mon, 30 Apr 2012 20:19:11 +0000 (14:19 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 1 May 2012 20:58:14 +0000 (14:58 -0600)
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.

tools/virsh.c

index e1776846c231143b27346e134feec78da1335a42..7159744895e2318e5cb0b322406c73b39a04db43 100644 (file)
@@ -20179,7 +20179,6 @@ vshAllowedEscapeChar(char c)
 static bool
 vshParseArgv(vshControl *ctl, int argc, char **argv)
 {
-    bool help = false;
     int arg, len;
     struct option opt[] = {
         {"debug", required_argument, NULL, 'd'},
@@ -20206,7 +20205,8 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
             }
             break;
         case 'h':
-            help = true;
+            vshUsage();
+            exit(EXIT_SUCCESS);
             break;
         case 'q':
             ctl->quiet = true;
@@ -20251,17 +20251,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) {
         /* parse command */
         ctl->imode = false;