]>
Commit | Line | Data |
---|---|---|
c6060300 MT |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.445 | |
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.445 (after 7.3.443) | |
11 | Problem: Can't properly escape commands for cmd.exe. | |
12 | Solution: Default 'shellxquote' to '('. Append ')' to make '(command)'. | |
13 | No need to use "/s" for 'shellcmdflag'. | |
14 | Files: src/misc2.c, src/option.c, src/os_win32.c | |
15 | ||
16 | ||
17 | *** ../vim-7.3.444/src/misc2.c 2012-01-20 17:15:47.000000000 +0100 | |
18 | --- src/misc2.c 2012-02-16 05:34:37.000000000 +0100 | |
19 | *************** | |
20 | *** 3230,3236 **** | |
21 | { | |
22 | STRCPY(ncmd, p_sxq); | |
23 | STRCAT(ncmd, cmd); | |
24 | ! STRCAT(ncmd, p_sxq); | |
25 | retval = mch_call_shell(ncmd, opt); | |
26 | vim_free(ncmd); | |
27 | } | |
28 | --- 3230,3240 ---- | |
29 | { | |
30 | STRCPY(ncmd, p_sxq); | |
31 | STRCAT(ncmd, cmd); | |
32 | ! /* When 'shellxquote' is ( append ). | |
33 | ! * When 'shellxquote' is "( append )". */ | |
34 | ! STRCAT(ncmd, STRCMP(p_sxq, "(") == 0 ? (char_u *)")" | |
35 | ! : STRCMP(p_sxq, "\"(") == 0 ? (char_u *)")\"" | |
36 | ! : p_sxq); | |
37 | retval = mch_call_shell(ncmd, opt); | |
38 | vim_free(ncmd); | |
39 | } | |
40 | *** ../vim-7.3.444/src/option.c 2012-02-12 23:23:25.000000000 +0100 | |
41 | --- src/option.c 2012-02-19 18:08:48.000000000 +0100 | |
42 | *************** | |
43 | *** 3933,3959 **** | |
44 | * my path/to/echo" "my args to echo | |
45 | * when executed. | |
46 | * | |
47 | ! * To avoid this, use the /s argument in addition to /c to force the | |
48 | ! * stripping behavior, and also set shellxquote to automatically | |
49 | ! * surround the entire command in quotes (which get stripped as | |
50 | ! * noted). | |
51 | */ | |
52 | - | |
53 | - /* Set shellxquote default to add the quotes to be stripped. */ | |
54 | idx3 = findoption((char_u *)"sxq"); | |
55 | if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
56 | { | |
57 | ! p_sxq = (char_u *)"\""; | |
58 | options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
59 | } | |
60 | ||
61 | - /* Set shellcmdflag default to always strip the quotes, note the order | |
62 | - * between /s and /c is important or cmd.exe will treat the /s as part | |
63 | - * of the command to be executed. */ | |
64 | idx3 = findoption((char_u *)"shcf"); | |
65 | if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
66 | { | |
67 | ! p_shcf = (char_u *)"/s /c"; | |
68 | options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
69 | } | |
70 | } | |
71 | --- 3933,3954 ---- | |
72 | * my path/to/echo" "my args to echo | |
73 | * when executed. | |
74 | * | |
75 | ! * To avoid this, set shellxquote to surround the command in | |
76 | ! * parenthesis. This appears to make most commands work, without | |
77 | ! * breaking commands that worked previously, such as | |
78 | ! * '"path with spaces/cmd" "a&b"'. | |
79 | */ | |
80 | idx3 = findoption((char_u *)"sxq"); | |
81 | if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
82 | { | |
83 | ! p_sxq = (char_u *)"("; | |
84 | options[idx3].def_val[VI_DEFAULT] = p_sxq; | |
85 | } | |
86 | ||
87 | idx3 = findoption((char_u *)"shcf"); | |
88 | if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | |
89 | { | |
90 | ! p_shcf = (char_u *)"/c"; | |
91 | options[idx3].def_val[VI_DEFAULT] = p_shcf; | |
92 | } | |
93 | } | |
94 | *** ../vim-7.3.444/src/os_win32.c 2011-08-27 15:10:00.000000000 +0200 | |
95 | --- src/os_win32.c 2012-02-19 18:11:23.000000000 +0100 | |
96 | *************** | |
97 | *** 3908,3915 **** | |
98 | newcmd = lalloc(cmdlen, TRUE); | |
99 | if (newcmd != NULL) | |
100 | { | |
101 | ! char_u *cmdbase = (*cmd == '"' ? cmd + 1 : cmd); | |
102 | ||
103 | if ((STRNICMP(cmdbase, "start", 5) == 0) && vim_iswhite(cmdbase[5])) | |
104 | { | |
105 | STARTUPINFO si; | |
106 | --- 3908,3920 ---- | |
107 | newcmd = lalloc(cmdlen, TRUE); | |
108 | if (newcmd != NULL) | |
109 | { | |
110 | ! char_u *cmdbase = cmd; | |
111 | ||
112 | + /* Skip a leading ", ( and "(. */ | |
113 | + if (*cmdbase == '"' ) | |
114 | + ++cmdbase; | |
115 | + if (*cmdbase == '(') | |
116 | + ++cmdbase; | |
117 | if ((STRNICMP(cmdbase, "start", 5) == 0) && vim_iswhite(cmdbase[5])) | |
118 | { | |
119 | STARTUPINFO si; | |
120 | *************** | |
121 | *** 3953,3968 **** | |
122 | * empty, keep the double quotes around the command. | |
123 | * Otherwise remove the double quotes, they aren't needed | |
124 | * here, because we don't use a shell to run the command. */ | |
125 | ! if (*cmd == '"' && *p_sxq == NUL) | |
126 | { | |
127 | ! newcmd[0] = '"'; | |
128 | ! STRCPY(newcmd + 1, cmdbase); | |
129 | ! } | |
130 | ! else | |
131 | ! { | |
132 | ! STRCPY(newcmd, cmdbase); | |
133 | ! if (*cmd == '"' && *newcmd != NUL) | |
134 | ! newcmd[STRLEN(newcmd) - 1] = NUL; | |
135 | } | |
136 | ||
137 | /* | |
138 | --- 3958,3983 ---- | |
139 | * empty, keep the double quotes around the command. | |
140 | * Otherwise remove the double quotes, they aren't needed | |
141 | * here, because we don't use a shell to run the command. */ | |
142 | ! if (cmdbase > cmd) | |
143 | { | |
144 | ! if (STRNCMP(cmd, p_sxq, cmd - cmdbase) != 0) | |
145 | ! { | |
146 | ! STRCPY(newcmd, cmd); | |
147 | ! } | |
148 | ! else | |
149 | ! { | |
150 | ! char_u *p; | |
151 | ! | |
152 | ! STRCPY(newcmd, cmdbase); | |
153 | ! /* Remove a trailing ", ) and )" if they have a match | |
154 | ! * at the start of the command. */ | |
155 | ! p = newcmd + STRLEN(newcmd); | |
156 | ! if (p > newcmd && p[-1] == '"' && *cmd == '"') | |
157 | ! *--p = NUL; | |
158 | ! if (p > newcmd && p[-1] == ')' | |
159 | ! && (*cmd =='(' || cmd[1] == '(')) | |
160 | ! *--p = NUL; | |
161 | ! } | |
162 | } | |
163 | ||
164 | /* | |
165 | *************** | |
166 | *** 3970,3976 **** | |
167 | * inherit our handles which causes unpleasant dangling swap | |
168 | * files if we exit before the spawned process | |
169 | */ | |
170 | ! if (CreateProcess (NULL, // Executable name | |
171 | newcmd, // Command to execute | |
172 | NULL, // Process security attributes | |
173 | NULL, // Thread security attributes | |
174 | --- 3985,3991 ---- | |
175 | * inherit our handles which causes unpleasant dangling swap | |
176 | * files if we exit before the spawned process | |
177 | */ | |
178 | ! if (CreateProcess(NULL, // Executable name | |
179 | newcmd, // Command to execute | |
180 | NULL, // Process security attributes | |
181 | NULL, // Thread security attributes | |
182 | *** ../vim-7.3.444/src/version.c 2012-02-13 00:01:38.000000000 +0100 | |
183 | --- src/version.c 2012-02-19 18:01:46.000000000 +0100 | |
184 | *************** | |
185 | *** 716,717 **** | |
186 | --- 716,719 ---- | |
187 | { /* Add new patch number below this line */ | |
188 | + /**/ | |
189 | + 445, | |
190 | /**/ | |
191 | ||
192 | -- | |
193 | hundred-and-one symptoms of being an internet addict: | |
194 | 80. At parties, you introduce your spouse as your "service provider." | |
195 | ||
196 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
197 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
198 | \\\ an exciting new programming language -- http://www.Zimbu.org /// | |
199 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |