[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] ash: treat busybox as a builtin applet in standalone shell mode
From:       Ron Yorston <rmy () pobox ! com>
Date:       2016-05-19 12:36:11
Message-ID: 573db33b.zg0Xh2hnQ7/gNUO5%rmy () pobox ! com
[Download RAW message or body]

"busybox" doesn't appear in the list of applet names.  Pretend that
it does when in standalone shell mode.  This allows the binary to
be called "sh" while still allowing the command "busybox" to be run
from the shell.

function                                             old     new   delta
shellexec                                            241     287     +46
find_command                                         847     864     +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 63/0)               Total: 63 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
---
 shell/ash.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/shell/ash.c b/shell/ash.c
index faa45a8..4bc9ba2 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7463,6 +7463,11 @@ shellexec(char **argv, const char *path, int idx)
 			goto try_PATH;
 		}
 		e = errno;
+#if ENABLE_FEATURE_SH_STANDALONE
+	} else if (strcmp(argv[0], "busybox") == 0) {
+		tryexec(-1, bb_busybox_exec_path, argv, envp);
+		e = errno;
+#endif
 	} else {
  try_PATH:
 		e = ENOENT;
@@ -12387,7 +12392,7 @@ 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 (applet_no >= 0) {
+		if (applet_no >= 0 || strcmp(name, "busybox") == 0) {
 			entry->cmdtype = CMDNORMAL;
 			entry->u.index = -2 - applet_no;
 			return;
-- 
2.5.5

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic