From 8884ff80ee749c86b284ecdfe2dbf41a0e68f55a Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Thu, 23 Apr 2009 00:19:22 +1000 Subject: shell/ash: search for .exe automatically if .exe is not given --- shell/ash.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index cdbbeba33..b4e7b78a8 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -11265,13 +11265,33 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) #endif if (errno != ENOENT && errno != ENOTDIR) e = errno; +#ifdef __MINGW32__ + if (!strchr(name, '.')) { + int len = strlen(fullname); + fullname = stalloc(strlen(fullname) + 5); + memcpy(fullname+len, ".exe", 5); + stunalloc(fullname); + while (stat(fullname, &statb) < 0) { +#ifdef SYSV + if (errno == EINTR) + continue; +#endif + if (errno != ENOENT && errno != ENOTDIR) + e = errno; + + goto loop; + } + + break; + } +#endif goto loop; } e = EACCES; /* if we fail, this will be the error */ if (!S_ISREG(statb.st_mode)) continue; if (pathopt) { /* this is a %func directory */ - stalloc(strlen(fullname) + 1); + fullname = stalloc(strlen(fullname) + 1); readcmdfile(fullname); cmdp = cmdlookup(name, 0); if (cmdp == NULL || cmdp->cmdtype != CMDFUNCTION) -- cgit v1.2.3-55-g6feb