Karsten Hopp 24e118
To: vim_dev@googlegroups.com
Karsten Hopp 24e118
Subject: Patch 7.3.446
Karsten Hopp 24e118
Fcc: outbox
Karsten Hopp 24e118
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 24e118
Mime-Version: 1.0
Karsten Hopp 24e118
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 24e118
Content-Transfer-Encoding: 8bit
Karsten Hopp 24e118
------------
Karsten Hopp 24e118
Karsten Hopp 24e118
Patch 7.3.446 (after 7.3.445)
Karsten Hopp 24e118
Problem:    Win32: External commands with special characters don't work.
Karsten Hopp 24e118
Solution:   Add the 'shellxescape' option.
Karsten Hopp 24e118
Files:	    src/misc2.c, src/option.c, src/option.h, runtime/doc/options.txt
Karsten Hopp 24e118
Karsten Hopp 24e118
Karsten Hopp 24e118
*** ../vim-7.3.445/src/misc2.c	2012-02-19 18:19:24.000000000 +0100
Karsten Hopp 24e118
--- src/misc2.c	2012-02-20 22:05:22.000000000 +0100
Karsten Hopp 24e118
***************
Karsten Hopp 24e118
*** 3225,3235 ****
Karsten Hopp 24e118
  	    retval = mch_call_shell(cmd, opt);
Karsten Hopp 24e118
  	else
Karsten Hopp 24e118
  	{
Karsten Hopp 24e118
! 	    ncmd = alloc((unsigned)(STRLEN(cmd) + STRLEN(p_sxq) * 2 + 1));
Karsten Hopp 24e118
  	    if (ncmd != NULL)
Karsten Hopp 24e118
  	    {
Karsten Hopp 24e118
  		STRCPY(ncmd, p_sxq);
Karsten Hopp 24e118
! 		STRCAT(ncmd, cmd);
Karsten Hopp 24e118
  		/* When 'shellxquote' is ( append ).
Karsten Hopp 24e118
  		 * When 'shellxquote' is "( append )". */
Karsten Hopp 24e118
  		STRCAT(ncmd, STRCMP(p_sxq, "(") == 0 ? (char_u *)")"
Karsten Hopp 24e118
--- 3225,3243 ----
Karsten Hopp 24e118
  	    retval = mch_call_shell(cmd, opt);
Karsten Hopp 24e118
  	else
Karsten Hopp 24e118
  	{
Karsten Hopp 24e118
! 	    char_u *ecmd = cmd;
Karsten Hopp 24e118
! 
Karsten Hopp 24e118
! 	    if (*p_sxe != NUL && STRCMP(p_sxq, "(") == 0)
Karsten Hopp 24e118
! 	    {
Karsten Hopp 24e118
! 		ecmd = vim_strsave_escaped_ext(cmd, p_sxe, '^', FALSE);
Karsten Hopp 24e118
! 		if (ecmd == NULL)
Karsten Hopp 24e118
! 		    ecmd = cmd;
Karsten Hopp 24e118
! 	    }
Karsten Hopp 24e118
! 	    ncmd = alloc((unsigned)(STRLEN(ecmd) + STRLEN(p_sxq) * 2 + 1));
Karsten Hopp 24e118
  	    if (ncmd != NULL)
Karsten Hopp 24e118
  	    {
Karsten Hopp 24e118
  		STRCPY(ncmd, p_sxq);
Karsten Hopp 24e118
! 		STRCAT(ncmd, ecmd);
Karsten Hopp 24e118
  		/* When 'shellxquote' is ( append ).
Karsten Hopp 24e118
  		 * When 'shellxquote' is "( append )". */
Karsten Hopp 24e118
  		STRCAT(ncmd, STRCMP(p_sxq, "(") == 0 ? (char_u *)")"
Karsten Hopp 24e118
***************
Karsten Hopp 24e118
*** 3240,3245 ****
Karsten Hopp 24e118
--- 3248,3255 ----
Karsten Hopp 24e118
  	    }
Karsten Hopp 24e118
  	    else
Karsten Hopp 24e118
  		retval = -1;
Karsten Hopp 24e118
+ 	    if (ecmd != cmd)
Karsten Hopp 24e118
+ 		vim_free(ecmd);
Karsten Hopp 24e118
  	}
Karsten Hopp 24e118
  #ifdef FEAT_GUI
Karsten Hopp 24e118
  	--hold_gui_events;
Karsten Hopp 24e118
*** ../vim-7.3.445/src/option.c	2012-02-19 18:19:24.000000000 +0100
Karsten Hopp 24e118
--- src/option.c	2012-02-20 22:01:07.000000000 +0100
Karsten Hopp 24e118
***************
Karsten Hopp 24e118
*** 2273,2278 ****
Karsten Hopp 24e118
--- 2273,2287 ----
Karsten Hopp 24e118
  			    (char_u *)"",
Karsten Hopp 24e118
  #endif
Karsten Hopp 24e118
  				(char_u *)0L} SCRIPTID_INIT},
Karsten Hopp 24e118
+     {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
Karsten Hopp 24e118
+ 			    (char_u *)&p_sxe, PV_NONE,
Karsten Hopp 24e118
+ 			    {
Karsten Hopp 24e118
+ #if defined(MSDOS) || defined(WIN16) || defined(WIN3264)
Karsten Hopp 24e118
+ 			    (char_u *)"\"&|<>()@^",
Karsten Hopp 24e118
+ #else
Karsten Hopp 24e118
+ 			    (char_u *)"",
Karsten Hopp 24e118
+ #endif
Karsten Hopp 24e118
+ 				(char_u *)0L} SCRIPTID_INIT},
Karsten Hopp 24e118
      {"shiftround",  "sr",   P_BOOL|P_VI_DEF|P_VIM,
Karsten Hopp 24e118
  			    (char_u *)&p_sr, PV_NONE,
Karsten Hopp 24e118
  			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Karsten Hopp 24e118
*** ../vim-7.3.445/src/option.h	2011-10-20 21:09:25.000000000 +0200
Karsten Hopp 24e118
--- src/option.h	2012-02-20 21:45:31.000000000 +0100
Karsten Hopp 24e118
***************
Karsten Hopp 24e118
*** 712,717 ****
Karsten Hopp 24e118
--- 712,718 ----
Karsten Hopp 24e118
  #endif
Karsten Hopp 24e118
  EXTERN char_u	*p_shq;		/* 'shellquote' */
Karsten Hopp 24e118
  EXTERN char_u	*p_sxq;		/* 'shellxquote' */
Karsten Hopp 24e118
+ EXTERN char_u	*p_sxe;		/* 'shellxescape' */
Karsten Hopp 24e118
  EXTERN char_u	*p_srr;		/* 'shellredir' */
Karsten Hopp 24e118
  #ifdef AMIGA
Karsten Hopp 24e118
  EXTERN long	p_st;		/* 'shelltype' */
Karsten Hopp 24e118
*** ../vim-7.3.445/runtime/doc/options.txt	2012-02-12 23:23:25.000000000 +0100
Karsten Hopp 24e118
--- runtime/doc/options.txt	2012-02-20 22:09:19.000000000 +0100
Karsten Hopp 24e118
***************
Karsten Hopp 24e118
*** 6023,6030 ****
Karsten Hopp 24e118
  
Karsten Hopp 24e118
  						*'shellxquote'* *'sxq'*
Karsten Hopp 24e118
  'shellxquote' 'sxq'	string	(default: "";
Karsten Hopp 24e118
! 					for Win32, when 'shell' is cmd.exe or
Karsten Hopp 24e118
! 					contains "sh" somewhere: "\""
Karsten Hopp 24e118
  					for Unix, when using system(): "\"")
Karsten Hopp 24e118
  			global
Karsten Hopp 24e118
  			{not in Vi}
Karsten Hopp 24e118
--- 6042,6050 ----
Karsten Hopp 24e118
  
Karsten Hopp 24e118
  						*'shellxquote'* *'sxq'*
Karsten Hopp 24e118
  'shellxquote' 'sxq'	string	(default: "";
Karsten Hopp 24e118
! 					for Win32, when 'shell' is cmd.exe: "("
Karsten Hopp 24e118
! 					for Win32, when 'shell' contains "sh"
Karsten Hopp 24e118
! 					somewhere: "\""
Karsten Hopp 24e118
  					for Unix, when using system(): "\"")
Karsten Hopp 24e118
  			global
Karsten Hopp 24e118
  			{not in Vi}
Karsten Hopp 24e118
***************
Karsten Hopp 24e118
*** 6032,6037 ****
Karsten Hopp 24e118
--- 6052,6060 ----
Karsten Hopp 24e118
  	the "!" and ":!" commands.  Includes the redirection.  See
Karsten Hopp 24e118
  	'shellquote' to exclude the redirection.  It's probably not useful
Karsten Hopp 24e118
  	to set both options.
Karsten Hopp 24e118
+ 	When the value is '(' then ')' is appended. When the value is '"('
Karsten Hopp 24e118
+ 	then ')"' is appended.
Karsten Hopp 24e118
+ 	When the value is '(' then also see 'shellxescape'.
Karsten Hopp 24e118
  	This is an empty string by default on most systems, but is known to be
Karsten Hopp 24e118
  	useful for on Win32 version, either for cmd.exe which automatically
Karsten Hopp 24e118
  	strips off the first and last quote on a command, or 3rd-party shells
Karsten Hopp 24e118
***************
Karsten Hopp 24e118
*** 6041,6046 ****
Karsten Hopp 24e118
--- 6064,6079 ----
Karsten Hopp 24e118
  	This option cannot be set from a |modeline| or in the |sandbox|, for
Karsten Hopp 24e118
  	security reasons.
Karsten Hopp 24e118
  
Karsten Hopp 24e118
+ 						*'shellxescape'* *'sxe'*
Karsten Hopp 24e118
+ 'shellxescape' 'sxe'	string	(default: "";
Karsten Hopp 24e118
+ 				 for MS-DOS and MS-Windows: "\"&|<>()@^")
Karsten Hopp 24e118
+ 			global
Karsten Hopp 24e118
+ 			{not in Vi}
Karsten Hopp 24e118
+ 	When 'shellxquote' is set to "(" then the characters listed in this
Karsten Hopp 24e118
+ 	option will be escaped with a '^' character.  This makes it possible
Karsten Hopp 24e118
+ 	to execute most external commands with cmd.exe.
Karsten Hopp 24e118
+ 
Karsten Hopp 24e118
+ 
Karsten Hopp 24e118
  			*'shiftround'* *'sr'* *'noshiftround'* *'nosr'*
Karsten Hopp 24e118
  'shiftround' 'sr'	boolean	(default off)
Karsten Hopp 24e118
  			global
Karsten Hopp 24e118
*** ../vim-7.3.445/src/version.c	2012-02-19 18:19:24.000000000 +0100
Karsten Hopp 24e118
--- src/version.c	2012-02-20 22:12:32.000000000 +0100
Karsten Hopp 24e118
***************
Karsten Hopp 24e118
*** 716,717 ****
Karsten Hopp 24e118
--- 716,719 ----
Karsten Hopp 24e118
  {   /* Add new patch number below this line */
Karsten Hopp 24e118
+ /**/
Karsten Hopp 24e118
+     446,
Karsten Hopp 24e118
  /**/
Karsten Hopp 24e118
Karsten Hopp 24e118
-- 
Karsten Hopp 24e118
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 24e118
86. E-mail Deficiency Depression (EDD) forces you to e-mail yourself.
Karsten Hopp 24e118
Karsten Hopp 24e118
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 24e118
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 24e118
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 24e118
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///