//config: at build time. Like applets, scripts can be run as
//config: 'busybox SCRIPT ...' or by linking their name to the binary.
//config:
+//config: This also allows applets to be implemented as scripts: place
+//config: the script in 'applets_sh' and a stub C file containing
+//config: configuration in the appropriate subsystem directory.
+//config:
//config:endif # ash options
//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
}
INT_OFF;
- nameeq = ckmalloc(namelen + vallen + 2);
+ nameeq = ckzalloc(namelen + vallen + 2);
p = mempcpy(nameeq, name, namelen);
if (val) {
*p++ = '=';
- p = mempcpy(p, val, vallen);
+ memcpy(p, val, vallen);
}
- *p = '\0';
vp = setvareq(nameeq, flags | VNOSAVE);
INT_ON;
{
#if ENABLE_FEATURE_SH_STANDALONE
if (applet_no >= 0) {
-# if NUM_SCRIPTS > 0
- if (applet_no >= NUM_APPLETS)
- goto run_script;
-# endif
if (APPLET_IS_NOEXEC(applet_no)) {
clearenv();
while (*envp)
#endif
if (cmd != bb_busybox_exec_path && errno == ENOEXEC) {
-#if ENABLE_FEATURE_SH_STANDALONE && NUM_SCRIPTS > 0
- run_script:
-#endif
/* Run "cmd" as a shell script:
* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
* "If the execve() function fails with ENOEXEC, the shell
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);
*/
/* 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;
heredoclist = NULL;
while (here) {
+ tokpushback = 0;
setprompt_if(needprompt, 2);
readtoken1(pgetc(), here->here->type == NHERE ? SQSYNTAX : DQSYNTAX,
here->eofmark, here->striptabs);
#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;
int login_sh;
xargv = argv;
+ login_sh = xargv[0] && xargv[0][0] == '-';
#if NUM_SCRIPTS > 0
if (minusc)
goto setarg0;
#endif
- login_sh = xargv[0] && xargv[0][0] == '-';
arg0 = xargv[0];
/* if (xargv[0]) - mmm, this is always true! */
xargv++;
* is used to figure out how far we had gotten.
*/
int ash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+#if NUM_SCRIPTS > 0
+int ash_main(int argc, char **argv)
+#else
int ash_main(int argc UNUSED_PARAM, char **argv)
+#endif
/* note: 'argc' is used only if embedded scripts are enabled */
{
volatile smallint state;