[libvirt] [PATCH 6/8] virsh: add escaper \ for command string parsing

Lai Jiangshan laijs at cn.fujitsu.com
Tue Oct 12 07:14:10 UTC 2010


add escaper \ for command string parsing, example:

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

Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
diff --git a/tools/virsh.c b/tools/virsh.c
index 9fd0602..b96071d 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10235,7 +10235,11 @@ copy:
         if (!double_quote && (*p == ' ' || *p == '\t' || *p == ';'))
             break;
 
-	if (*p == '"') {
+        if (*p == '\\') { /* escape */
+            p++;
+            if (*p == '\0')
+                break;
+        } else if (*p == '"') { /* double quote */
             double_quote = !double_quote;
             p++;
             continue;




More information about the libvir-list mailing list