//config: default y
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help
-//config: Allow scripts to be compressed and embedded in the BusyBox
+//config: Allow scripts to be compressed and embedded in the busybox
//config: binary. The scripts should be placed in the 'embed' directory
-//config: at build time. In standalone shell mode such scripts can be
-//config: run directly and are subject to tab completion; otherwise they
-//config: can be run by giving their name as an argument to the shell.
-//config: For convenience shell aliases are created. The '-L' shell
-//config: argument lists the names of the scripts. Like applets scripts
-//config: can be run as 'busybox name ...' or by linking their name to
-//config: the binary.
+//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
}
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;
#else
execve(cmd, argv, envp);
#endif
+
if (cmd != bb_busybox_exec_path && errno == ENOEXEC) {
/* Run "cmd" as a shell script:
* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
heredoclist = NULL;
while (here) {
+ tokpushback = 0;
setprompt_if(needprompt, 2);
readtoken1(pgetc(), here->here->type == NHERE ? SQSYNTAX : DQSYNTAX,
here->eofmark, here->striptabs);
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;