diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index 7a2d0ab68..0a638b1df 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -2828,6 +2828,10 @@ padvance_magic(const char **path, const char *name, int magic) | |||
2828 | const char *start; | 2828 | const char *start; |
2829 | size_t qlen; | 2829 | size_t qlen; |
2830 | size_t len; | 2830 | size_t len; |
2831 | #if ENABLE_PLATFORM_MINGW32 | ||
2832 | size_t sdlen = 0; | ||
2833 | const char *sd; | ||
2834 | #endif | ||
2831 | 2835 | ||
2832 | if (*path == NULL) | 2836 | if (*path == NULL) |
2833 | return -1; | 2837 | return -1; |
@@ -2859,11 +2863,20 @@ padvance_magic(const char **path, const char *name, int magic) | |||
2859 | *path = *p == PATH_SEP ? p + 1 : NULL; | 2863 | *path = *p == PATH_SEP ? p + 1 : NULL; |
2860 | 2864 | ||
2861 | /* "2" is for '/' and '\0' */ | 2865 | /* "2" is for '/' and '\0' */ |
2862 | /* reserve space for suffix on WIN32 */ | 2866 | qlen = len + strlen(name) + 2; |
2863 | qlen = len + strlen(name) + 2 IF_PLATFORM_MINGW32(+ 4); | 2867 | #if ENABLE_PLATFORM_MINGW32 |
2868 | /* reserve space for system drive prefix and extension */ | ||
2869 | sd = need_system_drive(start); | ||
2870 | if (sd != NULL) | ||
2871 | sdlen = strlen(sd); | ||
2872 | qlen += 4 + sdlen; | ||
2873 | #endif | ||
2864 | q = growstackto(qlen); | 2874 | q = growstackto(qlen); |
2865 | 2875 | ||
2866 | if (len) { | 2876 | if (len) { |
2877 | #if ENABLE_PLATFORM_MINGW32 | ||
2878 | q = mempcpy(q, sd, sdlen); | ||
2879 | #endif | ||
2867 | q = mempcpy(q, start, len); | 2880 | q = mempcpy(q, start, len); |
2868 | #if ENABLE_PLATFORM_MINGW32 | 2881 | #if ENABLE_PLATFORM_MINGW32 |
2869 | if (q[-1] != '/' && q[-1] != '\\') | 2882 | if (q[-1] != '/' && q[-1] != '\\') |
@@ -8740,6 +8753,9 @@ static void shellexec(char *prog, char **argv, const char *path, int idx) | |||
8740 | || (applet_no = find_applet_by_name(prog)) >= 0 | 8753 | || (applet_no = find_applet_by_name(prog)) >= 0 |
8741 | #endif | 8754 | #endif |
8742 | ) { | 8755 | ) { |
8756 | #if ENABLE_PLATFORM_MINGW32 | ||
8757 | prog = auto_add_system_drive(prog); | ||
8758 | #endif | ||
8743 | tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp); | 8759 | tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp); |
8744 | if (applet_no >= 0) { | 8760 | if (applet_no >= 0) { |
8745 | /* We tried execing ourself, but it didn't work. | 8761 | /* We tried execing ourself, but it didn't work. |
@@ -9176,7 +9192,16 @@ describe_command(char *command, const char *path, int describe_command_verbose) | |||
9176 | int j = entry.u.index; | 9192 | int j = entry.u.index; |
9177 | char *p; | 9193 | char *p; |
9178 | if (j < 0) { | 9194 | if (j < 0) { |
9195 | #if ENABLE_PLATFORM_MINGW32 | ||
9196 | /* can't use auto_add_system_drive, need space for extension */ | ||
9197 | const char *sd = need_system_drive(command); | ||
9198 | size_t len = strlen(command) + 5 + (sd ? strlen(sd) : 0); | ||
9199 | |||
9200 | p = auto_string(xmalloc(len)); | ||
9201 | sprintf(p, "%s%s", sd ? sd : "", command); | ||
9202 | #else | ||
9179 | p = command; | 9203 | p = command; |
9204 | #endif | ||
9180 | } else { | 9205 | } else { |
9181 | do { | 9206 | do { |
9182 | padvance(&path, command); | 9207 | padvance(&path, command); |
@@ -14246,6 +14271,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
14246 | /* If name contains a slash, don't use PATH or hash table */ | 14271 | /* If name contains a slash, don't use PATH or hash table */ |
14247 | #if ENABLE_PLATFORM_MINGW32 | 14272 | #if ENABLE_PLATFORM_MINGW32 |
14248 | if (has_path(name)) { | 14273 | if (has_path(name)) { |
14274 | name = auto_add_system_drive(name); | ||
14249 | #else | 14275 | #else |
14250 | if (strchr(name, '/') != NULL) { | 14276 | if (strchr(name, '/') != NULL) { |
14251 | #endif | 14277 | #endif |