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 <laijs@cn.fujitsu.com>
This commit is contained in:
Lai Jiangshan 2010-10-12 15:14:10 +08:00 committed by Eric Blake
parent 2f72becc31
commit 5232101487

View 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;