}
-static char* strcpy_backslash_escaped(char *t, const char *s, const char *bad, bool escape_tab_nl) {
+static char* strcpy_backslash_escaped(char *t, const char *s, const char *bad) {
assert(bad);
for (; *s; s++) {
- if (escape_tab_nl && IN_SET(*s, '\n', '\t')) {
+ if (IN_SET(*s, '\n', '\t')) {
*(t++) = '\\';
*(t++) = *s == '\n' ? 'n' : 't';
continue;
if (!r)
return NULL;
- t = strcpy_backslash_escaped(r, s, bad, false);
+ t = strcpy_backslash_escaped(r, s, bad);
*t = 0;
return r;
t = mempcpy(t, s, p - s);
t = strcpy_backslash_escaped(t, p,
- FLAGS_SET(flags, SHELL_ESCAPE_POSIX) ? SHELL_NEED_ESCAPE_POSIX : SHELL_NEED_ESCAPE,
- true);
+ FLAGS_SET(flags, SHELL_ESCAPE_POSIX) ? SHELL_NEED_ESCAPE_POSIX : SHELL_NEED_ESCAPE);
if (FLAGS_SET(flags, SHELL_ESCAPE_POSIX))
*(t++) = '\'';
test_shell_escape_one("foobar", "", "foobar");
test_shell_escape_one("foobar", "o", "f\\o\\obar");
test_shell_escape_one("foo:bar,baz", ",:", "foo\\:bar\\,baz");
+ test_shell_escape_one("foo\nbar\nbaz", ",:", "foo\\nbar\\nbaz");
}
static void test_shell_maybe_quote_one(const char *s, ShellEscapeFlags flags, const char *expected) {