diff src/misc2.c @ 5690:40f18a1c1592 v7.4.191

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.
author Bram Moolenaar <bram@vim.org>
date Sun, 23 Feb 2014 23:39:13 +0100
parents 6a28a9cf5153
children 50dbef5e774a
line wrap: on
line diff
--- 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_speci
 # 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_speci
 		++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)