diff options
author | Ron Yorston <rmy@pobox.com> | 2015-06-02 16:25:17 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2015-06-02 16:25:17 +0100 |
commit | 57e14f8704700ee39855698238d7e397e770332d (patch) | |
tree | dda6c968d0921a0b64bf9cfb58c5d9be5e19a3ab | |
parent | 7bf5f10016ef3d99d4a6a45b6a300d04d930de2a (diff) | |
download | busybox-w32-57e14f8704700ee39855698238d7e397e770332d.tar.gz busybox-w32-57e14f8704700ee39855698238d7e397e770332d.tar.bz2 busybox-w32-57e14f8704700ee39855698238d7e397e770332d.zip |
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.
-rw-r--r-- | shell/ash.c | 21 |
1 files changed, 21 insertions, 0 deletions
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 ** | |||
7764 | } | 7764 | } |
7765 | } | 7765 | } |
7766 | 7766 | ||
7767 | #if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE | ||
7768 | /* check if command and executable are both busybox */ | ||
7769 | static int busybox_cmd_and_exe(const char *name) | ||
7770 | { | ||
7771 | return strcmp(name, "busybox") == 0 && | ||
7772 | strcmp(bb_basename(bb_busybox_exec_path), "busybox.exe") == 0; | ||
7773 | } | ||
7774 | #endif | ||
7775 | |||
7767 | /* | 7776 | /* |
7768 | * Exec a program. Never returns. If you change this routine, you may | 7777 | * Exec a program. Never returns. If you change this routine, you may |
7769 | * have to change the find_command routine as well. | 7778 | * have to change the find_command routine as well. |
@@ -7794,6 +7803,10 @@ shellexec(char **argv, const char *path, int idx) | |||
7794 | goto try_PATH; | 7803 | goto try_PATH; |
7795 | } | 7804 | } |
7796 | e = errno; | 7805 | e = errno; |
7806 | #if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE | ||
7807 | } else if (busybox_cmd_and_exe(argv[0])) { | ||
7808 | tryexec(-1, bb_busybox_exec_path, argv, envp); | ||
7809 | #endif | ||
7797 | } else { | 7810 | } else { |
7798 | try_PATH: | 7811 | try_PATH: |
7799 | e = ENOENT; | 7812 | e = ENOENT; |
@@ -12769,6 +12782,14 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
12769 | return; | 12782 | return; |
12770 | } | 12783 | } |
12771 | 12784 | ||
12785 | #if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE | ||
12786 | if (busybox_cmd_and_exe(name)) { | ||
12787 | entry->u.index = -1; | ||
12788 | entry->cmdtype = CMDNORMAL; | ||
12789 | return; | ||
12790 | } | ||
12791 | #endif | ||
12792 | |||
12772 | /* #if ENABLE_FEATURE_SH_STANDALONE... moved after builtin check */ | 12793 | /* #if ENABLE_FEATURE_SH_STANDALONE... moved after builtin check */ |
12773 | 12794 | ||
12774 | updatetbl = (path == pathval()); | 12795 | updatetbl = (path == pathval()); |