]>
Commit | Line | Data |
---|---|---|
03d4279c AM |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.443 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.443 | |
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 | |
14 | ||
15 | ||
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 | |
18 | *************** | |
19 | *** 3883,3889 **** | |
20 | ||
21 | #if defined(MSDOS) || defined(WIN3264) || defined(OS2) | |
22 | /* | |
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 | |
27 | --- 3883,3890 ---- | |
28 | ||
29 | #if defined(MSDOS) || defined(WIN3264) || defined(OS2) | |
30 | /* | |
31 | ! * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the | |
32 | ! * 'shell' option. | |
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 | |
36 | *************** | |
37 | *** 3920,3925 **** | |
38 | --- 3921,3962 ---- | |
39 | # endif | |
40 | # endif | |
41 | } | |
42 | + else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) | |
43 | + { | |
44 | + int idx3; | |
45 | + | |
46 | + /* | |
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" | |
50 | + * become: | |
51 | + * my path/to/echo" "my args to echo | |
52 | + * when executed. | |
53 | + * | |
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 | |
57 | + * noted). | |
58 | + */ | |
59 | + | |
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)) | |
63 | + { | |
64 | + p_sxq = (char_u *)"\""; | |
65 | + options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
66 | + } | |
67 | + | |
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)) | |
73 | + { | |
74 | + p_shcf = (char_u *)"/s /c"; | |
75 | + options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
76 | + } | |
77 | + } | |
78 | #endif | |
79 | ||
80 | #ifdef FEAT_TITLE | |
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 | |
83 | *************** | |
84 | *** 5880,5895 **** | |
85 | security reasons. | |
86 | ||
87 | *'shellcmdflag'* *'shcf'* | |
88 | ! 'shellcmdflag' 'shcf' string (default: "-c", MS-DOS and Win32, when 'shell' | |
89 | ! does not contain "sh" somewhere: "/c") | |
90 | global | |
91 | {not in Vi} | |
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 | |
99 | security reasons. | |
100 | ||
101 | --- 5899,5919 ---- | |
102 | security reasons. | |
103 | ||
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") | |
109 | global | |
110 | {not in Vi} | |
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 | |
121 | security reasons. | |
122 | ||
123 | *************** | |
124 | *** 5910,5918 **** | |
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 | |
134 | --- 5934,5943 ---- | |
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 | |
141 | ! "sh". | |
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 | |
145 | *************** | |
146 | *** 6017,6024 **** | |
147 | ||
148 | *'shellxquote'* *'sxq'* | |
149 | 'shellxquote' 'sxq' string (default: ""; | |
150 | ! for Win32, when 'shell' contains "sh" | |
151 | ! somewhere: "\"" | |
152 | for Unix, when using system(): "\"") | |
153 | global | |
154 | {not in Vi} | |
155 | --- 6043,6050 ---- | |
156 | ||
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(): "\"") | |
162 | global | |
163 | {not in Vi} | |
164 | *************** | |
165 | *** 6026,6036 **** | |
166 | the "!" and ":!" commands. Includes the redirection. See | |
167 | 'shellquote' to exclude the redirection. It's probably not useful | |
168 | to set both options. | |
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 | |
175 | security reasons. | |
176 | ||
177 | --- 6052,6063 ---- | |
178 | the "!" and ":!" commands. Includes the redirection. See | |
179 | 'shellquote' to exclude the redirection. It's probably not useful | |
180 | to set both options. | |
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 | |
188 | security reasons. | |
189 | ||
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 | |
192 | *************** | |
193 | *** 716,717 **** | |
194 | --- 716,719 ---- | |
195 | { /* Add new patch number below this line */ | |
196 | + /**/ | |
197 | + 443, | |
198 | /**/ | |
199 | ||
200 | -- | |
201 | CVS sux, men don't like commitment | |
202 | ||
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 /// |