From: Lai Jiangshan Date: Tue, 12 Oct 2010 07:14:10 +0000 (+0800) Subject: virsh: add escaper \ for command string parsing X-Git-Tag: v0.8.5~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5232101487993f5fd9d2d6627e13e38ffe61e5a2;p=thirdparty%2Flibvirt.git virsh: add escaper \ for command string parsing add escaper \ for command string parsing, example: virsh # cd /path/which/have/a/double\"quote Signed-off-by: Lai Jiangshan --- diff --git a/tools/virsh.c b/tools/virsh.c index 4101161ede..493d096dc6 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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;