summaryrefslogtreecommitdiff
path: root/src/misc2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-02-23 23:39:13 +0100
committerBram Moolenaar <Bram@vim.org>2014-02-23 23:39:13 +0100
commit26df092843de91ea0c5c5c130d0d0695d2d81c07 (patch)
treea049c605f9dee06d777ad030b291ddf782cfcdb9 /src/misc2.c
parent581966e8323c2bab6f9e54729708dc46de8f9fc5 (diff)
downloadvim-26df092843de91ea0c5c5c130d0d0695d2d81c07.zip
updated for version 7.4.191
Problem: Escaping a file name for shell commands can't be done without a function. Solution: Add the :S file name modifier.
Diffstat (limited to 'src/misc2.c')
-rw-r--r--src/misc2.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/misc2.c b/src/misc2.c
index a9d7a82b0..8f8b2d9d4 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1369,12 +1369,14 @@ csh_like_shell()
* Escape a newline, depending on the 'shell' option.
* When "do_special" is TRUE also replace "!", "%", "#" and things starting
* with "<" like "<cfile>".
+ * When "do_newline" is FALSE do not escape newline unless it is csh shell.
* Returns the result in allocated memory, NULL if we have run out.
*/
char_u *
-vim_strsave_shellescape(string, do_special)
+vim_strsave_shellescape(string, do_special, do_newline)
char_u *string;
int do_special;
+ int do_newline;
{
unsigned length;
char_u *p;
@@ -1403,7 +1405,8 @@ vim_strsave_shellescape(string, do_special)
# endif
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)
@@ -1454,7 +1457,8 @@ vim_strsave_shellescape(string, 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)