diff options
Diffstat (limited to 'libbb/executable.c')
-rw-r--r-- | libbb/executable.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libbb/executable.c b/libbb/executable.c index e20bf89e4..32b37f29d 100644 --- a/libbb/executable.c +++ b/libbb/executable.c | |||
@@ -15,7 +15,12 @@ | |||
15 | int FAST_FUNC file_is_executable(const char *name) | 15 | int FAST_FUNC file_is_executable(const char *name) |
16 | { | 16 | { |
17 | struct stat s; | 17 | struct stat s; |
18 | #if !ENABLE_PLATFORM_MINGW32 | ||
18 | return (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode)); | 19 | return (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode)); |
20 | #else | ||
21 | /* expand WIN32 implementation of access(2) */ | ||
22 | return (!stat(name, &s) && S_ISREG(s.st_mode) && (s.st_mode & S_IXUSR)); | ||
23 | #endif | ||
19 | } | 24 | } |
20 | 25 | ||
21 | /* search (*PATHp) for an executable file; | 26 | /* search (*PATHp) for an executable file; |
@@ -53,12 +58,13 @@ char* FAST_FUNC find_executable(const char *filename, char **PATHp) | |||
53 | #if ENABLE_PLATFORM_MINGW32 | 58 | #if ENABLE_PLATFORM_MINGW32 |
54 | { | 59 | { |
55 | char *w = alloc_system_drive(p); | 60 | char *w = alloc_system_drive(p); |
56 | add_win32_extension(w); | 61 | ex = add_win32_extension(w) || file_is_executable(w); |
57 | free(p); | 62 | free(p); |
58 | p = w; | 63 | p = w; |
59 | } | 64 | } |
60 | #endif | 65 | #else |
61 | ex = file_is_executable(p); | 66 | ex = file_is_executable(p); |
67 | #endif | ||
62 | if (n) *n++ = PATH_SEP; | 68 | if (n) *n++ = PATH_SEP; |
63 | if (ex) { | 69 | if (ex) { |
64 | *PATHp = n; | 70 | *PATHp = n; |