]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: add -- support
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 12 Oct 2010 07:14:22 +0000 (15:14 +0800)
committerEric Blake <eblake@redhat.com>
Wed, 13 Oct 2010 13:52:33 +0000 (07:52 -0600)
"--" means no option at the following arguments.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
tools/virsh.c

index 255803b67f3f7a73437a0889fdf8246f4a8732b7..bae647000a50c441c037c2e5bd4548532bde73a4 100644 (file)
@@ -10469,6 +10469,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
         vshCmdOpt *last = NULL;
         const vshCmdDef *cmd = NULL;
         vshCommandToken tk;
+        bool data_only = false;
         int data_ct = 0;
 
         first = NULL;
@@ -10491,8 +10492,10 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
                     goto syntaxError;   /* ... or ignore this command only? */
                 }
                 VIR_FREE(tkdata);
-            } else if (*tkdata == '-' && *(tkdata + 1) == '-' && *(tkdata + 2)
-                       && c_isalnum(*(tkdata + 2))) {
+            } else if (data_only) {
+                goto get_data;
+            } else if (tkdata[0] == '-' && tkdata[1] == '-' &&
+                       c_isalnum(tkdata[2])) {
                 char *optstr = strchr(tkdata + 2, '=');
                 if (optstr) {
                     *optstr = '\0'; /* convert the '=' to '\0' */
@@ -10532,7 +10535,12 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
                         goto syntaxError;
                     }
                 }
+            } else if (tkdata[0] == '-' && tkdata[1] == '-' &&
+                       tkdata[2] == '\0') {
+                data_only = true;
+                continue;
             } else {
+get_data:
                 if (!(opt = vshCmddefGetData(cmd, data_ct++))) {
                     vshError(ctl, _("unexpected data '%s'"), tkdata);
                     goto syntaxError;