From 57e14f8704700ee39855698238d7e397e770332d Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 2 Jun 2015 16:25:17 +0100 Subject: ash: skip PATH if executable and command are both busybox If the command is 'busybox' and the executable is 'busybox.exe' don't bother checking PATH, just run the executable. This means that busybox.exe can be somewhere other than on PATH. --- shell/ash.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 34d5af446..0d188e1e6 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7764,6 +7764,15 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char ** } } +#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE +/* check if command and executable are both busybox */ +static int busybox_cmd_and_exe(const char *name) +{ + return strcmp(name, "busybox") == 0 && + strcmp(bb_basename(bb_busybox_exec_path), "busybox.exe") == 0; +} +#endif + /* * Exec a program. Never returns. If you change this routine, you may * have to change the find_command routine as well. @@ -7794,6 +7803,10 @@ shellexec(char **argv, const char *path, int idx) goto try_PATH; } e = errno; +#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE + } else if (busybox_cmd_and_exe(argv[0])) { + tryexec(-1, bb_busybox_exec_path, argv, envp); +#endif } else { try_PATH: e = ENOENT; @@ -12769,6 +12782,14 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) return; } +#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE + if (busybox_cmd_and_exe(name)) { + entry->u.index = -1; + entry->cmdtype = CMDNORMAL; + return; + } +#endif + /* #if ENABLE_FEATURE_SH_STANDALONE... moved after builtin check */ updatetbl = (path == pathval()); -- cgit v1.2.3-55-g6feb