diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 15 | ||||
-rw-r--r-- | win32/process.c | 11 |
2 files changed, 25 insertions, 1 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 8501ecdd4..e63ffa0ac 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1698,6 +1698,21 @@ const char *get_system_drive(void) | |||
1698 | return drive; | 1698 | return drive; |
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | /* Return pointer to system drive if path is of form '/file', else NULL */ | ||
1702 | const char *need_system_drive(const char *path) | ||
1703 | { | ||
1704 | if (root_len(path) == 0 && (path[0] == '/' || path[0] == '\\')) | ||
1705 | return get_system_drive(); | ||
1706 | return NULL; | ||
1707 | } | ||
1708 | |||
1709 | /* Add a system drive prefix to 'path' if necessary, else return 'path' */ | ||
1710 | char *auto_add_system_drive(const char *path) | ||
1711 | { | ||
1712 | const char *sd = need_system_drive(path); | ||
1713 | return sd ? auto_string(concat_path_file(sd, path)) : (char *)path; | ||
1714 | } | ||
1715 | |||
1701 | int chdir_system_drive(void) | 1716 | int chdir_system_drive(void) |
1702 | { | 1717 | { |
1703 | const char *sd = get_system_drive(); | 1718 | const char *sd = get_system_drive(); |
diff --git a/win32/process.c b/win32/process.c index 1118eb18a..cd164e0ed 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -63,6 +63,7 @@ static int | |||
63 | parse_interpreter(const char *cmd, interp_t *interp) | 63 | parse_interpreter(const char *cmd, interp_t *interp) |
64 | { | 64 | { |
65 | char *path, *t; | 65 | char *path, *t; |
66 | const char *sd; | ||
66 | int n; | 67 | int n; |
67 | 68 | ||
68 | while (TRUE) { | 69 | while (TRUE) { |
@@ -88,6 +89,12 @@ parse_interpreter(const char *cmd, interp_t *interp) | |||
88 | if (*t == '\0') | 89 | if (*t == '\0') |
89 | break; | 90 | break; |
90 | 91 | ||
92 | sd = need_system_drive(path); | ||
93 | if (sd && strlen(sd) == 2) { | ||
94 | path -= 2; | ||
95 | memcpy(path, sd, 2); | ||
96 | } | ||
97 | |||
91 | interp->path = path; | 98 | interp->path = path; |
92 | interp->name = t; | 99 | interp->name = t; |
93 | interp->opts = strtok(NULL, "\r\n"); | 100 | interp->opts = strtok(NULL, "\r\n"); |
@@ -342,6 +349,7 @@ static intptr_t | |||
342 | mingw_spawn_1(int mode, const char *cmd, char *const *argv, char *const *envp) | 349 | mingw_spawn_1(int mode, const char *cmd, char *const *argv, char *const *envp) |
343 | { | 350 | { |
344 | char *prog; | 351 | char *prog; |
352 | const char *path; | ||
345 | 353 | ||
346 | #if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE | 354 | #if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE |
347 | if (find_applet_by_name(cmd) >= 0) | 355 | if (find_applet_by_name(cmd) >= 0) |
@@ -349,7 +357,8 @@ mingw_spawn_1(int mode, const char *cmd, char *const *argv, char *const *envp) | |||
349 | else | 357 | else |
350 | #endif | 358 | #endif |
351 | if (has_path(cmd)) { | 359 | if (has_path(cmd)) { |
352 | const char *path = auto_win32_extension(cmd); | 360 | cmd = auto_add_system_drive(cmd); |
361 | path = auto_win32_extension(cmd); | ||
353 | return mingw_spawn_interpreter(mode, path ? path : cmd, argv, envp, 0); | 362 | return mingw_spawn_interpreter(mode, path ? path : cmd, argv, envp, 0); |
354 | } | 363 | } |
355 | else if ((prog=find_first_executable(cmd)) != NULL) { | 364 | else if ((prog=find_first_executable(cmd)) != NULL) { |