diff options
Diffstat (limited to 'src/misc2.c')
-rw-r--r-- | src/misc2.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/misc2.c b/src/misc2.c index 997fafc7ff..7b471a5811 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -691,11 +691,12 @@ int csh_like_shell(void) * This uses single quotes, except when we know we need to use double quotes * (MS-DOS and MS-Windows without 'shellslash' set). * Escape a newline, depending on the 'shell' option. - * When "do_special" is TRUE also replace "!", "%", "#" and things starting + * When "do_special" is true also replace "!", "%", "#" and things starting * with "<" like "<cfile>". - * Returns the result in allocated memory, NULL if we have run out. + * When "do_newline" is false do not escape newline unless it is csh shell. + * Returns the result in allocated memory. */ -char_u *vim_strsave_shellescape(char_u *string, int do_special) +char_u *vim_strsave_shellescape(char_u *string, bool do_special, bool do_newline) { unsigned length; char_u *p; @@ -715,7 +716,8 @@ char_u *vim_strsave_shellescape(char_u *string, int do_special) for (p = string; *p != NUL; mb_ptr_adv(p)) { if (*p == '\'') length += 3; /* ' => '\'' */ - if (*p == '\n' || (*p == '!' && (csh_like || do_special))) { + if ((*p == '\n' && (csh_like || do_newline)) + || (*p == '!' && (csh_like || do_special))) { ++length; /* insert backslash */ if (csh_like && do_special) ++length; /* insert backslash */ @@ -742,7 +744,8 @@ char_u *vim_strsave_shellescape(char_u *string, int do_special) ++p; continue; } - if (*p == '\n' || (*p == '!' && (csh_like || do_special))) { + if ((*p == '\n' && (csh_like || do_newline)) + || (*p == '!' && (csh_like || do_special))) { *d++ = '\\'; if (csh_like && do_special) *d++ = '\\'; |