diff options
author | Ron Yorston <rmy@pobox.com> | 2018-02-26 10:08:50 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-02-26 10:08:50 +0000 |
commit | 00f2d33f37da42e17e5d978958659c4899cb2f0a (patch) | |
tree | 5d43272aa7c6a4f3be2dd4f9e9d1edf3963ec69d /win32/process.c | |
parent | 7288179d1218f8e0308455d4d58346aec268eb2e (diff) | |
download | busybox-w32-00f2d33f37da42e17e5d978958659c4899cb2f0a.tar.gz busybox-w32-00f2d33f37da42e17e5d978958659c4899cb2f0a.tar.bz2 busybox-w32-00f2d33f37da42e17e5d978958659c4899cb2f0a.zip |
win32: add support for batch files
Support batch files with .bat and .cmd extensions, similar to
what's done for .exe and .com.
Check extensions in the same order as Windows' spawn function:
.com, .exe, .bat, .cmd.
Diffstat (limited to 'win32/process.c')
-rw-r--r-- | win32/process.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/win32/process.c b/win32/process.c index a0e8b96e0..da83d1c96 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -203,6 +203,34 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env) | |||
203 | new_argv[i] = quote_arg(argv[i]); | 203 | new_argv[i] = quote_arg(argv[i]); |
204 | new_argv[argc] = NULL; | 204 | new_argv[argc] = NULL; |
205 | 205 | ||
206 | /* | ||
207 | * Special case: spawnve won't execute a batch file when the path | ||
208 | * starts with a '.' and contains forward slashes. | ||
209 | */ | ||
210 | if (new_argv[0][0] == '.') { | ||
211 | char *s, *p; | ||
212 | |||
213 | if (has_bat_suffix(new_argv[0])) { | ||
214 | p = strdup(new_argv[0]); | ||
215 | } | ||
216 | else { | ||
217 | p = file_is_win32_executable(new_argv[0]); | ||
218 | } | ||
219 | |||
220 | if (p != NULL && has_bat_suffix(p)) { | ||
221 | for (s=p; *s; ++s) { | ||
222 | if (*s == '/') | ||
223 | *s = '\\'; | ||
224 | } | ||
225 | if (new_argv[0] != argv[0]) | ||
226 | free(new_argv[0]); | ||
227 | new_argv[0] = p; | ||
228 | } | ||
229 | else { | ||
230 | free(p); | ||
231 | } | ||
232 | } | ||
233 | |||
206 | ret = spawnve(mode, path, new_argv, env); | 234 | ret = spawnve(mode, path, new_argv, env); |
207 | 235 | ||
208 | for (i = 0;i < argc;i++) | 236 | for (i = 0;i < argc;i++) |