aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorGravatar Ron Yorston <rmy@pobox.com>2018-11-01 11:04:47 +0100
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2018-11-01 11:07:26 +0100
commit151de441e7a19ce3afba0c59b083240a801222cf (patch)
treeab4574bf623c162848b20d6495d139df23e337fd /shell
parentaa2959c90d9c3217ddb6f482b82fef7234ad9bde (diff)
downloadbusybox-151de441e7a19ce3afba0c59b083240a801222cf.tar.gz
busybox-151de441e7a19ce3afba0c59b083240a801222cf.tar.bz2
ash: recognize embedded scripts in SH_STANDALONE mode
function old new delta find_script_by_name - 51 +51 shellexec 254 271 +17 find_command 990 1007 +17 evalcommand 1653 1661 +8 doCommands 2233 2222 -11 run_applet_and_exit 128 100 -28 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 6/4 up/down: 104/-52) Total: 52 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 3adb6d0d2..58ecf6d2c 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8085,6 +8085,9 @@ static void shellexec(char *prog, char **argv, const char *path, int idx)
if (strchr(prog, '/') != NULL
#if ENABLE_FEATURE_SH_STANDALONE
|| (applet_no = find_applet_by_name(prog)) >= 0
+# if NUM_SCRIPTS > 0
+ || (applet_no = NUM_APPLETS + find_script_by_name(prog)) >= 0
+# endif
#endif
) {
tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp);
@@ -10186,6 +10189,10 @@ evalcommand(union node *cmd, int flags)
*/
/* find_command() encodes applet_no as (-2 - applet_no) */
int applet_no = (- cmdentry.u.index - 2);
+# if NUM_SCRIPTS > 0
+ /* Applets are ok, but not embedded scripts */
+ if (applet_no < NUM_APPLETS)
+# endif
if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) {
char **sv_environ;
@@ -13368,6 +13375,11 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
#if ENABLE_FEATURE_SH_STANDALONE
{
int applet_no = find_applet_by_name(name);
+# if NUM_SCRIPTS > 0
+ if (applet_no < 0)
+ /* embedded script indices are offset by NUM_APPLETS */
+ applet_no = NUM_APPLETS + find_script_by_name(name);
+# endif
if (applet_no >= 0) {
entry->cmdtype = CMDNORMAL;
entry->u.index = -2 - applet_no;