/* Tests of multiple commands. */
DO_TEST(36, "a\nb\n", " echo a; echo b;");
DO_TEST(37, "a\nb\n", "\necho a\n echo b\n");
+ DO_TEST(38, "a\nb\n", "ec\\\nho a\n echo \\\n b;");
+ DO_TEST(39, "a\n b\n", "\"ec\\\nho\" a\n echo \"\\\n b\";");
+ DO_TEST(40, "a\n\\\n b\n", "ec\\\nho a\n echo '\\\n b';");
# undef DO_TEST
command and its arguments on the shell command line, or a I<COMMAND_STRING>
which is a single shell argument consisting of multiple I<COMMAND> actions
and their arguments joined with whitespace and separated by semicolons or
-newlines between commands. Within I<COMMAND_STRING>, virsh understands the
+newlines between commands, where unquoted backslash-newline pairs are
+elided. Within I<COMMAND_STRING>, virsh understands the
same single, double, and backslash escapes as the shell, although you must
add another layer of shell escaping in creating the single shell argument.
If no command is given in the command line, B<virsh> will then start a minimal
command and its arguments on the shell command line, or a I<COMMAND_STRING>
which is a single shell argument consisting of multiple I<COMMAND> actions
and their arguments joined with whitespace and separated by semicolons or
-newlines between commands. Within I<COMMAND_STRING>, virt-admin understands the
+newlines between commands, where unquoted backslash-newline pairs are
+elided. Within I<COMMAND_STRING>, virt-admin understands the
same single, double, and backslash escapes as the shell, although you must
add another layer of shell escaping in creating the single shell argument.
If no command is given in the command line, B<virt-admin> will then start a minimal
*res = q;
- while (*p && (*p == ' ' || *p == '\t'))
- p++;
+ while (*p == ' ' || *p == '\t' || (*p == '\\' && p[1] == '\n'))
+ p += 1 + (*p == '\\');
if (*p == '\0')
return VSH_TK_END;
continue;
} else if (!single_quote && *p == '\\') { /* escape */
/*
- * The same as the bash, a \ in "" is an escaper,
+ * The same as in shell, a \ in "" is an escaper,
* but a \ in '' is not an escaper.
*/
p++;
if (report)
vshError(ctl, "%s", _("dangling \\"));
return VSH_TK_ERROR;
+ } else if (*p == '\n') {
+ /* Elide backslash-newline entirely */
+ p++;
+ continue;
}
} else if (!single_quote && *p == '"') { /* double quote */
double_quote = !double_quote;