1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: MS-Windows: 'shcf' and 'shellxquote' defaults are not very good.
12 Solution: Make a better guess when 'shell' is set to "cmd.exe". (Ben Fritz)
13 Files: src/option.c, runtime/doc/options.txt
16 *** ../vim-7.3.442/src/option.c 2012-01-28 18:03:30.000000000 +0100
17 --- src/option.c 2012-02-12 23:17:55.000000000 +0100
21 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
23 ! * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option.
24 * This is done after other initializations, where 'shell' might have been
25 * set, but only if they have not been set before. Default for p_shcf is
26 * "/c", for p_shq is "". For "sh" like shells it is changed here to
29 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
31 ! * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
33 * This is done after other initializations, where 'shell' might have been
34 * set, but only if they have not been set before. Default for p_shcf is
35 * "/c", for p_shq is "". For "sh" like shells it is changed here to
42 + else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
47 + * cmd.exe on Windows will strip the first and last double quote given
48 + * on the command line, e.g. most of the time things like:
49 + * cmd /c "my path/to/echo" "my args to echo"
51 + * my path/to/echo" "my args to echo
54 + * To avoid this, use the /s argument in addition to /c to force the
55 + * stripping behavior, and also set shellxquote to automatically
56 + * surround the entire command in quotes (which get stripped as
60 + /* Set shellxquote default to add the quotes to be stripped. */
61 + idx3 = findoption((char_u *)"sxq");
62 + if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
64 + p_sxq = (char_u *)"\"";
65 + options[idx3].def_val[VI_DEFAULT] = p_sxq;
68 + /* Set shellcmdflag default to always strip the quotes, note the order
69 + * between /s and /c is important or cmd.exe will treat the /s as part
70 + * of the command to be executed. */
71 + idx3 = findoption((char_u *)"shcf");
72 + if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
74 + p_shcf = (char_u *)"/s /c";
75 + options[idx3].def_val[VI_DEFAULT] = p_shcf;
81 *** ../vim-7.3.442/runtime/doc/options.txt 2011-06-26 05:36:07.000000000 +0200
82 --- runtime/doc/options.txt 2012-02-12 23:21:59.000000000 +0100
87 *'shellcmdflag'* *'shcf'*
88 ! 'shellcmdflag' 'shcf' string (default: "-c", MS-DOS and Win32, when 'shell'
89 ! does not contain "sh" somewhere: "/c")
92 Flag passed to the shell to execute "!" and ":!" commands; e.g.,
93 "bash.exe -c ls" or "command.com /c dir". For the MS-DOS-like
94 systems, the default is set according to the value of 'shell', to
95 reduce the need to set this option by the user. It's not used for
96 ! OS/2 (EMX figures this out itself). See |option-backslash| about
97 ! including spaces and backslashes. See |dos-shell|.
98 This option cannot be set from a |modeline| or in the |sandbox|, for
104 *'shellcmdflag'* *'shcf'*
105 ! 'shellcmdflag' 'shcf' string (default: "-c";
106 ! Win32, when 'shell' is cmd.exe: "/s /c";
107 ! MS-DOS and Win32, when 'shell' neither is
108 ! cmd.exe nor contains "sh" somewhere: "/c")
111 Flag passed to the shell to execute "!" and ":!" commands; e.g.,
112 "bash.exe -c ls" or "command.com /c dir". For the MS-DOS-like
113 systems, the default is set according to the value of 'shell', to
114 reduce the need to set this option by the user. It's not used for
115 ! OS/2 (EMX figures this out itself).
116 ! On Unix it can have more than one flag. Each white space separated
117 ! part is passed as an argument to the shell command.
118 ! See |option-backslash| about including spaces and backslashes.
119 ! Also see |dos-shell| for MS-DOS and MS-Windows.
120 This option cannot be set from a |modeline| or in the |sandbox|, for
125 For Unix the default it "| tee". The stdout of the compiler is saved
126 in a file and echoed to the screen. If the 'shell' option is "csh" or
127 "tcsh" after initializations, the default becomes "|& tee". If the
128 ! 'shell' option is "sh", "ksh", "zsh" or "bash" the default becomes
129 ! "2>&1| tee". This means that stderr is also included. Before using
130 ! the 'shell' option a path is removed, thus "/bin/sh" uses "sh".
131 The initialization of this option is done after reading the ".vimrc"
132 and the other initializations, so that when the 'shell' option is set
133 there, the 'shellpipe' option changes automatically, unless it was
135 For Unix the default it "| tee". The stdout of the compiler is saved
136 in a file and echoed to the screen. If the 'shell' option is "csh" or
137 "tcsh" after initializations, the default becomes "|& tee". If the
138 ! 'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh" or "bash" the
139 ! default becomes "2>&1| tee". This means that stderr is also included.
140 ! Before using the 'shell' option a path is removed, thus "/bin/sh" uses
142 The initialization of this option is done after reading the ".vimrc"
143 and the other initializations, so that when the 'shell' option is set
144 there, the 'shellpipe' option changes automatically, unless it was
148 *'shellxquote'* *'sxq'*
149 'shellxquote' 'sxq' string (default: "";
150 ! for Win32, when 'shell' contains "sh"
152 for Unix, when using system(): "\"")
157 *'shellxquote'* *'sxq'*
158 'shellxquote' 'sxq' string (default: "";
159 ! for Win32, when 'shell' is cmd.exe or
160 ! contains "sh" somewhere: "\""
161 for Unix, when using system(): "\"")
166 the "!" and ":!" commands. Includes the redirection. See
167 'shellquote' to exclude the redirection. It's probably not useful
169 ! This is an empty string by default. Known to be useful for
170 ! third-party shells when using the Win32 version, such as the MKS Korn
171 ! Shell or bash, where it should be "\"". The default is adjusted
172 ! according the value of 'shell', to reduce the need to set this option
173 ! by the user. See |dos-shell|.
174 This option cannot be set from a |modeline| or in the |sandbox|, for
178 the "!" and ":!" commands. Includes the redirection. See
179 'shellquote' to exclude the redirection. It's probably not useful
181 ! This is an empty string by default on most systems, but is known to be
182 ! useful for on Win32 version, either for cmd.exe which automatically
183 ! strips off the first and last quote on a command, or 3rd-party shells
184 ! such as the MKS Korn Shell or bash, where it should be "\"". The
185 ! default is adjusted according the value of 'shell', to reduce the need
186 ! to set this option by the user. See |dos-shell|.
187 This option cannot be set from a |modeline| or in the |sandbox|, for
190 *** ../vim-7.3.442/src/version.c 2012-02-12 20:13:55.000000000 +0100
191 --- src/version.c 2012-02-12 23:18:40.000000000 +0100
195 { /* Add new patch number below this line */
201 CVS sux, men don't like commitment
203 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
204 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
205 \\\ an exciting new programming language -- http://www.Zimbu.org ///
206 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///