summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.3.443
blob: 84b45baa255f05f651680c3525f68249d5bb914c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
To: vim_dev@googlegroups.com
Subject: Patch 7.3.443
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.443
Problem:    MS-Windows: 'shcf' and 'shellxquote' defaults are not very good.
Solution:   Make a better guess when 'shell' is set to "cmd.exe". (Ben Fritz)
Files:      src/option.c, runtime/doc/options.txt


*** ../vim-7.3.442/src/option.c	2012-01-28 18:03:30.000000000 +0100
--- src/option.c	2012-02-12 23:17:55.000000000 +0100
***************
*** 3883,3889 ****
  
  #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
      /*
!      * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option.
       * This is done after other initializations, where 'shell' might have been
       * set, but only if they have not been set before.  Default for p_shcf is
       * "/c", for p_shq is "".  For "sh" like  shells it is changed here to
--- 3883,3890 ----
  
  #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
      /*
!      * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
!      * 'shell' option.
       * This is done after other initializations, where 'shell' might have been
       * set, but only if they have not been set before.  Default for p_shcf is
       * "/c", for p_shq is "".  For "sh" like  shells it is changed here to
***************
*** 3920,3925 ****
--- 3921,3962 ----
  #  endif
  # endif
      }
+     else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
+     {
+ 	int	idx3;
+ 
+ 	/*
+ 	 * cmd.exe on Windows will strip the first and last double quote given
+ 	 * on the command line, e.g. most of the time things like:
+ 	 *   cmd /c "my path/to/echo" "my args to echo"
+ 	 * become:
+ 	 *   my path/to/echo" "my args to echo
+ 	 * when executed.
+ 	 *
+ 	 * To avoid this, use the /s argument in addition to /c to force the
+ 	 * stripping behavior, and also set shellxquote to automatically
+ 	 * surround the entire command in quotes (which get stripped as
+ 	 * noted).
+ 	 */
+ 
+ 	/* Set shellxquote default to add the quotes to be stripped. */
+ 	idx3 = findoption((char_u *)"sxq");
+ 	if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
+ 	{
+ 	    p_sxq = (char_u *)"\"";
+ 	    options[idx3].def_val[VI_DEFAULT] = p_sxq;
+ 	}
+ 
+ 	/* Set shellcmdflag default to always strip the quotes, note the order
+ 	 * between /s and /c is important or cmd.exe will treat the /s as part
+ 	 * of the command to be executed.  */
+ 	idx3 = findoption((char_u *)"shcf");
+ 	if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
+ 	{
+ 	    p_shcf = (char_u *)"/s /c";
+ 	    options[idx3].def_val[VI_DEFAULT] = p_shcf;
+ 	}
+     }
  #endif
  
  #ifdef FEAT_TITLE
*** ../vim-7.3.442/runtime/doc/options.txt	2011-06-26 05:36:07.000000000 +0200
--- runtime/doc/options.txt	2012-02-12 23:21:59.000000000 +0100
***************
*** 5880,5895 ****
  	security reasons.
  
  						*'shellcmdflag'* *'shcf'*
! 'shellcmdflag' 'shcf'	string	(default: "-c", MS-DOS and Win32, when 'shell'
! 					does not contain "sh" somewhere: "/c")
  			global
  			{not in Vi}
  	Flag passed to the shell to execute "!" and ":!" commands; e.g.,
  	"bash.exe -c ls" or "command.com /c dir".  For the MS-DOS-like
  	systems, the default is set according to the value of 'shell', to
  	reduce the need to set this option by the user.  It's not used for
! 	OS/2 (EMX figures this out itself).  See |option-backslash| about
! 	including spaces and backslashes.  See |dos-shell|.
  	This option cannot be set from a |modeline| or in the |sandbox|, for
  	security reasons.
  
--- 5899,5919 ----
  	security reasons.
  
  						*'shellcmdflag'* *'shcf'*
! 'shellcmdflag' 'shcf'	string	(default: "-c";
! 				 Win32, when 'shell' is cmd.exe: "/s /c";
! 				 MS-DOS and Win32, when 'shell' neither is
! 				 cmd.exe nor contains "sh" somewhere: "/c")
  			global
  			{not in Vi}
  	Flag passed to the shell to execute "!" and ":!" commands; e.g.,
  	"bash.exe -c ls" or "command.com /c dir".  For the MS-DOS-like
  	systems, the default is set according to the value of 'shell', to
  	reduce the need to set this option by the user.  It's not used for
! 	OS/2 (EMX figures this out itself).
! 	On Unix it can have more than one flag.  Each white space separated
! 	part is passed as an argument to the shell command.
! 	See |option-backslash| about including spaces and backslashes.
! 	Also see |dos-shell| for MS-DOS and MS-Windows.
  	This option cannot be set from a |modeline| or in the |sandbox|, for
  	security reasons.
  
***************
*** 5910,5918 ****
  	For Unix the default it "| tee".  The stdout of the compiler is saved
  	in a file and echoed to the screen.  If the 'shell' option is "csh" or
  	"tcsh" after initializations, the default becomes "|& tee".  If the
! 	'shell' option is "sh", "ksh", "zsh" or "bash" the default becomes
! 	"2>&1| tee".  This means that stderr is also included.  Before using
! 	the 'shell' option a path is removed, thus "/bin/sh" uses "sh".
  	The initialization of this option is done after reading the ".vimrc"
  	and the other initializations, so that when the 'shell' option is set
  	there, the 'shellpipe' option changes automatically, unless it was
--- 5934,5943 ----
  	For Unix the default it "| tee".  The stdout of the compiler is saved
  	in a file and echoed to the screen.  If the 'shell' option is "csh" or
  	"tcsh" after initializations, the default becomes "|& tee".  If the
! 	'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh" or "bash" the
! 	default becomes "2>&1| tee".  This means that stderr is also included.
! 	Before using the 'shell' option a path is removed, thus "/bin/sh" uses
! 	"sh".
  	The initialization of this option is done after reading the ".vimrc"
  	and the other initializations, so that when the 'shell' option is set
  	there, the 'shellpipe' option changes automatically, unless it was
***************
*** 6017,6024 ****
  
  						*'shellxquote'* *'sxq'*
  'shellxquote' 'sxq'	string	(default: "";
! 					for Win32, when 'shell' contains "sh"
! 					somewhere: "\""
  					for Unix, when using system(): "\"")
  			global
  			{not in Vi}
--- 6043,6050 ----
  
  						*'shellxquote'* *'sxq'*
  'shellxquote' 'sxq'	string	(default: "";
! 					for Win32, when 'shell' is cmd.exe or
! 					contains "sh" somewhere: "\""
  					for Unix, when using system(): "\"")
  			global
  			{not in Vi}
***************
*** 6026,6036 ****
  	the "!" and ":!" commands.  Includes the redirection.  See
  	'shellquote' to exclude the redirection.  It's probably not useful
  	to set both options.
! 	This is an empty string by default.  Known to be useful for
! 	third-party shells when using the Win32 version, such as the MKS Korn
! 	Shell or bash, where it should be "\"".  The default is adjusted
! 	according the value of 'shell', to reduce the need to set this option
! 	by the user.  See |dos-shell|.
  	This option cannot be set from a |modeline| or in the |sandbox|, for
  	security reasons.
  
--- 6052,6063 ----
  	the "!" and ":!" commands.  Includes the redirection.  See
  	'shellquote' to exclude the redirection.  It's probably not useful
  	to set both options.
! 	This is an empty string by default on most systems, but is known to be
! 	useful for on Win32 version, either for cmd.exe which automatically
! 	strips off the first and last quote on a command, or 3rd-party shells
! 	such as the MKS Korn Shell or bash, where it should be "\"".  The
! 	default is adjusted according the value of 'shell', to reduce the need
! 	to set this option by the user.  See |dos-shell|.
  	This option cannot be set from a |modeline| or in the |sandbox|, for
  	security reasons.
  
*** ../vim-7.3.442/src/version.c	2012-02-12 20:13:55.000000000 +0100
--- src/version.c	2012-02-12 23:18:40.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     443,
  /**/

-- 
CVS sux, men don't like commitment

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///