]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: add escaper \ for command string parsing
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 12 Oct 2010 07:14:10 +0000 (15:14 +0800)
committerEric Blake <eblake@redhat.com>
Wed, 13 Oct 2010 13:52:33 +0000 (07:52 -0600)
add escaper \ for command string parsing, example:

virsh # cd /path/which/have/a/double\"quote

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

index 4101161ede5bb5dbf1c272a18a6c794383f8bace..493d096dc6c60238544594527a690878af891b6c 100644 (file)
@@ -10406,7 +10406,13 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandParser *parser, char **res)
         if (!double_quote && (*p == ' ' || *p == '\t' || *p == ';'))
             break;
 
-        if (*p == '"') {
+        if (*p == '\\') { /* escape */
+            p++;
+            if (*p == '\0') {
+                vshError(ctl, "%s", _("dangling \\"));
+                return VSH_TK_ERROR;
+            }
+        } else if (*p == '"') { /* double quote */
             double_quote = !double_quote;
             p++;
             continue;