diff options
author | Ron Yorston <rmy@pobox.com> | 2017-07-24 10:27:04 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-07-24 10:27:04 +0100 |
commit | eeceafbc5c4caf513c6d92b7d71ecb0ccd89a3f8 (patch) | |
tree | 5a543fa18a66c64c8a8047e4534978aca945ff99 | |
parent | ac181bf548a3dd1aabaf8263d255936f66866cc7 (diff) | |
download | busybox-w32-eeceafbc5c4caf513c6d92b7d71ecb0ccd89a3f8.tar.gz busybox-w32-eeceafbc5c4caf513c6d92b7d71ecb0ccd89a3f8.tar.bz2 busybox-w32-eeceafbc5c4caf513c6d92b7d71ecb0ccd89a3f8.zip |
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
-rw-r--r-- | shell/ash.c | 11 |
1 files changed, 9 insertions, 2 deletions
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) | |||
13262 | struct tblentry *cmdp; | 13262 | struct tblentry *cmdp; |
13263 | int idx; | 13263 | int idx; |
13264 | int prev; | 13264 | int prev; |
13265 | char *fullname; | 13265 | char *fullname IF_PLATFORM_MINGW32(= NULL); |
13266 | struct stat statb; | 13266 | struct stat statb; |
13267 | int e; | 13267 | int e; |
13268 | int updatetbl; | 13268 | int updatetbl; |
@@ -13273,7 +13273,11 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
13273 | if (strchr(name, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(name, '\\'))) { | 13273 | if (strchr(name, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(name, '\\'))) { |
13274 | entry->u.index = -1; | 13274 | entry->u.index = -1; |
13275 | if (act & DO_ABS) { | 13275 | if (act & DO_ABS) { |
13276 | while (stat(name, &statb) < 0) { | 13276 | while (stat(name, &statb) < 0 |
13277 | #if ENABLE_PLATFORM_MINGW32 | ||
13278 | && (fullname=file_is_win32_executable(name)) == NULL | ||
13279 | #endif | ||
13280 | ) { | ||
13277 | #ifdef SYSV | 13281 | #ifdef SYSV |
13278 | if (errno == EINTR) | 13282 | if (errno == EINTR) |
13279 | continue; | 13283 | continue; |
@@ -13281,6 +13285,9 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
13281 | entry->cmdtype = CMDUNKNOWN; | 13285 | entry->cmdtype = CMDUNKNOWN; |
13282 | return; | 13286 | return; |
13283 | } | 13287 | } |
13288 | #if ENABLE_PLATFORM_MINGW32 | ||
13289 | free(fullname); | ||
13290 | #endif | ||
13284 | } | 13291 | } |
13285 | entry->cmdtype = CMDNORMAL; | 13292 | entry->cmdtype = CMDNORMAL; |
13286 | return; | 13293 | return; |