aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index dc1a55a6b..25468d796 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -148,6 +148,21 @@
148//config: you to run the specified command or builtin, 148//config: you to run the specified command or builtin,
149//config: even when there is a function with the same name. 149//config: even when there is a function with the same name.
150//config: 150//config:
151//config:config ASH_EMBEDDED_SCRIPTS
152//config: bool "Embed scripts in the binary"
153//config: default y
154//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
155//config: help
156//config: Allow scripts to be compressed and embedded in the BusyBox
157//config: binary. The scripts should be placed in the 'embed' directory
158//config: at build time. In standalone shell mode such scripts can be
159//config: run directly and are subject to tab completion; otherwise they
160//config: can be run by giving their name as an argument to the shell.
161//config: For convenience shell aliases are created. The '-L' shell
162//config: argument lists the names of the scripts. Like applets scripts
163//config: can be run as 'busybox name ...' or by linking their name to
164//config: the binary.
165//config:
151//config:endif # ash options 166//config:endif # ash options
152 167
153//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) 168//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
@@ -181,6 +196,11 @@
181#include <sys/times.h> 196#include <sys/times.h>
182#include <sys/utsname.h> /* for setting $HOSTNAME */ 197#include <sys/utsname.h> /* for setting $HOSTNAME */
183#include "busybox.h" /* for applet_names */ 198#include "busybox.h" /* for applet_names */
199#if ENABLE_ASH_EMBEDDED_SCRIPTS
200# include "embedded_scripts.h"
201#else
202# define NUM_SCRIPTS 0
203#endif
184 204
185/* So far, all bash compat is controlled by one config option */ 205/* So far, all bash compat is controlled by one config option */
186/* Separate defines document which part of code implements what */ 206/* Separate defines document which part of code implements what */
@@ -14021,13 +14041,17 @@ procargs(char **argv)
14021 int login_sh; 14041 int login_sh;
14022 14042
14023 xargv = argv; 14043 xargv = argv;
14044#if NUM_SCRIPTS > 0
14045 if (minusc)
14046 goto setarg0;
14047#endif
14024 login_sh = xargv[0] && xargv[0][0] == '-'; 14048 login_sh = xargv[0] && xargv[0][0] == '-';
14025 arg0 = xargv[0]; 14049 arg0 = xargv[0];
14026 /* if (xargv[0]) - mmm, this is always true! */ 14050 /* if (xargv[0]) - mmm, this is always true! */
14027 xargv++; 14051 xargv++;
14052 argptr = xargv;
14028 for (i = 0; i < NOPTS; i++) 14053 for (i = 0; i < NOPTS; i++)
14029 optlist[i] = 2; 14054 optlist[i] = 2;
14030 argptr = xargv;
14031 if (options(/*cmdline:*/ 1, &login_sh)) { 14055 if (options(/*cmdline:*/ 1, &login_sh)) {
14032 /* it already printed err message */ 14056 /* it already printed err message */
14033 raise_exception(EXERROR); 14057 raise_exception(EXERROR);
@@ -14130,6 +14154,7 @@ extern int etext();
14130 */ 14154 */
14131int ash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 14155int ash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
14132int ash_main(int argc UNUSED_PARAM, char **argv) 14156int ash_main(int argc UNUSED_PARAM, char **argv)
14157/* note: 'argc' is used only if embedded scripts are enabled */
14133{ 14158{
14134 volatile smallint state; 14159 volatile smallint state;
14135 struct jmploc jmploc; 14160 struct jmploc jmploc;
@@ -14183,6 +14208,12 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
14183 14208
14184 init(); 14209 init();
14185 setstackmark(&smark); 14210 setstackmark(&smark);
14211
14212#if NUM_SCRIPTS > 0
14213 if (argc < 0)
14214 /* Non-NULL minusc tells procargs that an embedded script is being run */
14215 minusc = get_script_content(-argc - 1);
14216#endif
14186 login_sh = procargs(argv); 14217 login_sh = procargs(argv);
14187#if DEBUG 14218#if DEBUG
14188 TRACE(("Shell args: ")); 14219 TRACE(("Shell args: "));