From eeceafbc5c4caf513c6d92b7d71ecb0ccd89a3f8 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 24 Jul 2017 10:27:04 +0100 Subject: ash: allow for filename extension in find_command When searching for a command specified as a pathname also check for the filename with a '.exe' or '.com' extension. Previously even if /bin/busybox.exe was present we got: $ command -v /bin/busybox $ echo $? 127 This now becomes: $ command -v /bin/busybox /bin/busybox $ echo $? 0 --- shell/ash.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 6cc29d25e..dc5561765 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -13262,7 +13262,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) struct tblentry *cmdp; int idx; int prev; - char *fullname; + char *fullname IF_PLATFORM_MINGW32(= NULL); struct stat statb; int e; int updatetbl; @@ -13273,7 +13273,11 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) if (strchr(name, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(name, '\\'))) { entry->u.index = -1; if (act & DO_ABS) { - while (stat(name, &statb) < 0) { + while (stat(name, &statb) < 0 +#if ENABLE_PLATFORM_MINGW32 + && (fullname=file_is_win32_executable(name)) == NULL +#endif + ) { #ifdef SYSV if (errno == EINTR) continue; @@ -13281,6 +13285,9 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) entry->cmdtype = CMDUNKNOWN; return; } +#if ENABLE_PLATFORM_MINGW32 + free(fullname); +#endif } entry->cmdtype = CMDNORMAL; return; -- cgit v1.2.3-55-g6feb