On 10/12/2010 01:14 AM, Lai Jiangshan wrote:
add escaper \ for command string parsing, example:
virsh # cd /path/which/have/a/double\quote
Signed-off-by: Lai Jiangshanla...@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;
Hmm - dangling \ should be an error, rather than silently discarded.
+} else if (*p == '') { /* double quote */
double_quote = !double_quote;
p++;
continue;
ACK with that fixed; here's what I'm squashing in.
diff --git i/tools/virsh.c w/tools/virsh.c
index d49d18a..16d141c 100644
--- i/tools/virsh.c
+++ w/tools/virsh.c
@@ -10261,8 +10261,10 @@ vshCommandStringGetArg(vshControl *ctl,
vshCommandParser *parser, char **res)
if (*p == '\\') { /* escape */
p++;
-if (*p == '\0')
-break;
+if (*p == '\0') {
+vshError(ctl, %s, _(dangling \\));
+return VSH_TK_ERROR;
+}
} else if (*p == '') { /* double quote */
double_quote = !double_quote;
p++;
--
Eric Blake ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list