Karsten Hopp 0c3fda
To: vim_dev@googlegroups.com
Karsten Hopp 0c3fda
Subject: Patch 7.3.448
Karsten Hopp 0c3fda
Fcc: outbox
Karsten Hopp 0c3fda
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 0c3fda
Mime-Version: 1.0
Karsten Hopp 0c3fda
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 0c3fda
Content-Transfer-Encoding: 8bit
Karsten Hopp 0c3fda
------------
Karsten Hopp 0c3fda
Karsten Hopp 0c3fda
Patch 7.3.448 (after 7.3.447)
Karsten Hopp 0c3fda
Problem:    Win32: Still a problem with "!start /b".
Karsten Hopp 0c3fda
Solution:   Escape only '|'. (Yasuhiro Matsumoto)
Karsten Hopp 0c3fda
Files:	    src/os_win32.c
Karsten Hopp 0c3fda
Karsten Hopp 0c3fda
Karsten Hopp 0c3fda
*** ../vim-7.3.447/src/os_win32.c	2012-02-21 21:22:40.000000000 +0100
Karsten Hopp 0c3fda
--- src/os_win32.c	2012-02-22 13:06:55.000000000 +0100
Karsten Hopp 0c3fda
***************
Karsten Hopp 0c3fda
*** 3933,3939 ****
Karsten Hopp 0c3fda
      else
Karsten Hopp 0c3fda
      {
Karsten Hopp 0c3fda
  	/* we use "command" or "cmd" to start the shell; slow but easy */
Karsten Hopp 0c3fda
! 	char_u *cmdbase = cmd;
Karsten Hopp 0c3fda
  
Karsten Hopp 0c3fda
  	/* Skip a leading ", ( and "(. */
Karsten Hopp 0c3fda
  	if (*cmdbase == '"' )
Karsten Hopp 0c3fda
--- 3933,3941 ----
Karsten Hopp 0c3fda
      else
Karsten Hopp 0c3fda
      {
Karsten Hopp 0c3fda
  	/* we use "command" or "cmd" to start the shell; slow but easy */
Karsten Hopp 0c3fda
! 	char_u	*newcmd = NULL;
Karsten Hopp 0c3fda
! 	char_u	*cmdbase = cmd;
Karsten Hopp 0c3fda
! 	long_u	cmdlen;
Karsten Hopp 0c3fda
  
Karsten Hopp 0c3fda
  	/* Skip a leading ", ( and "(. */
Karsten Hopp 0c3fda
  	if (*cmdbase == '"' )
Karsten Hopp 0c3fda
***************
Karsten Hopp 0c3fda
*** 3971,3982 ****
Karsten Hopp 0c3fda
  		flags = CREATE_NO_WINDOW;
Karsten Hopp 0c3fda
  		si.dwFlags = STARTF_USESTDHANDLES;
Karsten Hopp 0c3fda
  		si.hStdInput = CreateFile("\\\\.\\NUL",	// File name
Karsten Hopp 0c3fda
! 		    GENERIC_READ,				// Access flags
Karsten Hopp 0c3fda
  		    0,					// Share flags
Karsten Hopp 0c3fda
! 		    NULL,					// Security att.
Karsten Hopp 0c3fda
! 		    OPEN_EXISTING,				// Open flags
Karsten Hopp 0c3fda
! 		    FILE_ATTRIBUTE_NORMAL,			// File att.
Karsten Hopp 0c3fda
! 		    NULL);					// Temp file
Karsten Hopp 0c3fda
  		si.hStdOutput = si.hStdInput;
Karsten Hopp 0c3fda
  		si.hStdError = si.hStdInput;
Karsten Hopp 0c3fda
  	    }
Karsten Hopp 0c3fda
--- 3973,3984 ----
Karsten Hopp 0c3fda
  		flags = CREATE_NO_WINDOW;
Karsten Hopp 0c3fda
  		si.dwFlags = STARTF_USESTDHANDLES;
Karsten Hopp 0c3fda
  		si.hStdInput = CreateFile("\\\\.\\NUL",	// File name
Karsten Hopp 0c3fda
! 		    GENERIC_READ,			// Access flags
Karsten Hopp 0c3fda
  		    0,					// Share flags
Karsten Hopp 0c3fda
! 		    NULL,				// Security att.
Karsten Hopp 0c3fda
! 		    OPEN_EXISTING,			// Open flags
Karsten Hopp 0c3fda
! 		    FILE_ATTRIBUTE_NORMAL,		// File att.
Karsten Hopp 0c3fda
! 		    NULL);				// Temp file
Karsten Hopp 0c3fda
  		si.hStdOutput = si.hStdInput;
Karsten Hopp 0c3fda
  		si.hStdError = si.hStdInput;
Karsten Hopp 0c3fda
  	    }
Karsten Hopp 0c3fda
***************
Karsten Hopp 0c3fda
*** 3993,4004 ****
Karsten Hopp 0c3fda
  		    *--p = NUL;
Karsten Hopp 0c3fda
  	    }
Karsten Hopp 0c3fda
  
Karsten Hopp 0c3fda
  	    /*
Karsten Hopp 0c3fda
! 	     * Unescape characters in shellxescape. This is workaround for
Karsten Hopp 0c3fda
! 	     * /b option. Only redirect character should be unescaped.
Karsten Hopp 0c3fda
  	     */
Karsten Hopp 0c3fda
! 	    unescape_shellxquote(cmdbase,
Karsten Hopp 0c3fda
! 			(flags & CREATE_NEW_CONSOLE) ? p_sxe : "<>");
Karsten Hopp 0c3fda
  
Karsten Hopp 0c3fda
  	    /*
Karsten Hopp 0c3fda
  	     * Now, start the command as a process, so that it doesn't
Karsten Hopp 0c3fda
--- 3995,4030 ----
Karsten Hopp 0c3fda
  		    *--p = NUL;
Karsten Hopp 0c3fda
  	    }
Karsten Hopp 0c3fda
  
Karsten Hopp 0c3fda
+ 	    newcmd = cmdbase;
Karsten Hopp 0c3fda
+ 	    unescape_shellxquote(cmdbase, p_sxe);
Karsten Hopp 0c3fda
+ 
Karsten Hopp 0c3fda
  	    /*
Karsten Hopp 0c3fda
! 	     * If creating new console, arguments are passed to the
Karsten Hopp 0c3fda
! 	     * 'cmd.exe' as-is. If it's not, arguments are not treated
Karsten Hopp 0c3fda
! 	     * correctly for current 'cmd.exe'. So unescape characters in
Karsten Hopp 0c3fda
! 	     * shellxescape except '|' for avoiding to be treated as
Karsten Hopp 0c3fda
! 	     * argument to them. Pass the arguments to sub-shell.
Karsten Hopp 0c3fda
  	     */
Karsten Hopp 0c3fda
! 	    if (flags != CREATE_NEW_CONSOLE)
Karsten Hopp 0c3fda
! 	    {
Karsten Hopp 0c3fda
! 		char_u	*subcmd;
Karsten Hopp 0c3fda
! 		char_u	*cmd_shell = default_shell();
Karsten Hopp 0c3fda
! 
Karsten Hopp 0c3fda
! 		subcmd = vim_strsave_escaped_ext(cmdbase, "|", '^', FALSE);
Karsten Hopp 0c3fda
! 		if (subcmd != NULL)
Karsten Hopp 0c3fda
! 		{
Karsten Hopp 0c3fda
! 		    /* make "cmd.exe /c arguments" */
Karsten Hopp 0c3fda
! 		    cmdlen = STRLEN(cmd_shell) + STRLEN(subcmd) + 5;
Karsten Hopp 0c3fda
! 		    vim_free(subcmd);
Karsten Hopp 0c3fda
! 
Karsten Hopp 0c3fda
! 		    newcmd = lalloc(cmdlen, TRUE);
Karsten Hopp 0c3fda
! 		    if (newcmd != NULL)
Karsten Hopp 0c3fda
! 			vim_snprintf((char *)newcmd, cmdlen, "%s /c %s",
Karsten Hopp 0c3fda
! 						       default_shell, subcmd);
Karsten Hopp 0c3fda
! 		    else
Karsten Hopp 0c3fda
! 			newcmd = cmdbase;
Karsten Hopp 0c3fda
! 		}
Karsten Hopp 0c3fda
! 	    }
Karsten Hopp 0c3fda
  
Karsten Hopp 0c3fda
  	    /*
Karsten Hopp 0c3fda
  	     * Now, start the command as a process, so that it doesn't
Karsten Hopp 0c3fda
***************
Karsten Hopp 0c3fda
*** 4006,4012 ****
Karsten Hopp 0c3fda
  	     * files if we exit before the spawned process
Karsten Hopp 0c3fda
  	     */
Karsten Hopp 0c3fda
  	    if (CreateProcess(NULL,		// Executable name
Karsten Hopp 0c3fda
! 		    cmdbase,			// Command to execute
Karsten Hopp 0c3fda
  		    NULL,			// Process security attributes
Karsten Hopp 0c3fda
  		    NULL,			// Thread security attributes
Karsten Hopp 0c3fda
  		    FALSE,			// Inherit handles
Karsten Hopp 0c3fda
--- 4032,4038 ----
Karsten Hopp 0c3fda
  	     * files if we exit before the spawned process
Karsten Hopp 0c3fda
  	     */
Karsten Hopp 0c3fda
  	    if (CreateProcess(NULL,		// Executable name
Karsten Hopp 0c3fda
! 		    newcmd,			// Command to execute
Karsten Hopp 0c3fda
  		    NULL,			// Process security attributes
Karsten Hopp 0c3fda
  		    NULL,			// Thread security attributes
Karsten Hopp 0c3fda
  		    FALSE,			// Inherit handles
Karsten Hopp 0c3fda
***************
Karsten Hopp 0c3fda
*** 4023,4028 ****
Karsten Hopp 0c3fda
--- 4049,4058 ----
Karsten Hopp 0c3fda
  		EMSG(_("E371: Command not found"));
Karsten Hopp 0c3fda
  #endif
Karsten Hopp 0c3fda
  	    }
Karsten Hopp 0c3fda
+ 
Karsten Hopp 0c3fda
+ 	    if (newcmd != cmdbase)
Karsten Hopp 0c3fda
+ 		vim_free(newcmd);
Karsten Hopp 0c3fda
+ 
Karsten Hopp 0c3fda
  	    if (si.hStdInput != NULL)
Karsten Hopp 0c3fda
  	    {
Karsten Hopp 0c3fda
  		/* Close the handle to \\.\NUL */
Karsten Hopp 0c3fda
***************
Karsten Hopp 0c3fda
*** 4034,4041 ****
Karsten Hopp 0c3fda
  	}
Karsten Hopp 0c3fda
  	else
Karsten Hopp 0c3fda
  	{
Karsten Hopp 0c3fda
! 	    char_u *newcmd;
Karsten Hopp 0c3fda
! 	    long_u cmdlen =  (
Karsten Hopp 0c3fda
  #ifdef FEAT_GUI_W32
Karsten Hopp 0c3fda
  		(allowPiping && !p_stmp ? 0 : STRLEN(vimrun_path)) +
Karsten Hopp 0c3fda
  #endif
Karsten Hopp 0c3fda
--- 4064,4070 ----
Karsten Hopp 0c3fda
  	}
Karsten Hopp 0c3fda
  	else
Karsten Hopp 0c3fda
  	{
Karsten Hopp 0c3fda
! 	    cmdlen = (
Karsten Hopp 0c3fda
  #ifdef FEAT_GUI_W32
Karsten Hopp 0c3fda
  		(allowPiping && !p_stmp ? 0 : STRLEN(vimrun_path)) +
Karsten Hopp 0c3fda
  #endif
Karsten Hopp 0c3fda
*** ../vim-7.3.447/src/version.c	2012-02-21 21:22:40.000000000 +0100
Karsten Hopp 0c3fda
--- src/version.c	2012-02-22 13:02:15.000000000 +0100
Karsten Hopp 0c3fda
***************
Karsten Hopp 0c3fda
*** 716,717 ****
Karsten Hopp 0c3fda
--- 716,719 ----
Karsten Hopp 0c3fda
  {   /* Add new patch number below this line */
Karsten Hopp 0c3fda
+ /**/
Karsten Hopp 0c3fda
+     448,
Karsten Hopp 0c3fda
  /**/
Karsten Hopp 0c3fda
Karsten Hopp 0c3fda
-- 
Karsten Hopp 0c3fda
From "know your smileys":
Karsten Hopp 0c3fda
 ~#:-(	I just washed my hair, and I can't do nuthin' with it.
Karsten Hopp 0c3fda
Karsten Hopp 0c3fda
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 0c3fda
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 0c3fda
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 0c3fda
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///