}
# endif
+# if ENABLE_BUSYBOX || NUM_APPLETS > 0
static void run_applet_and_exit(const char *name, char **argv) NORETURN;
+#endif
# if NUM_SCRIPTS > 0
static int find_script_by_name(const char *name)
{
int script = find_script_by_name(applet_name);
if (script >= 0)
-#if ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH
+# if ENABLE_SHELL_ASH
exit(ash_main(-script - 1, argv));
-#elif ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH
+# elif ENABLE_SHELL_HUSH
exit(hush_main(-script - 1, argv));
-#else
+# else
return 1;
-#endif
+# endif
return 0;
}
}
# endif
-#endif /* !defined(SINGLE_APPLET_MAIN) */
+#else /* defined(SINGLE_APPLET_MAIN) */
+
+# if NUM_SCRIPTS > 0
+/* if SINGLE_APPLET_MAIN, these two functions are simpler: */
+int scripted_main(int argc UNUSED_PARAM, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int scripted_main(int argc UNUSED_PARAM, char **argv)
+{
+# if ENABLE_SHELL_ASH
+ int script = 0;
+ exit(ash_main(-script - 1, argv));
+# elif ENABLE_SHELL_HUSH
+ int script = 0;
+ exit(hush_main(-script - 1, argv));
+# else
+ return 1;
+# endif
+}
+char* FAST_FUNC
+get_script_content(unsigned n UNUSED_PARAM)
+{
+ char *t = unpack_bz2_data(packed_scripts, sizeof(packed_scripts),
+ UNPACKED_SCRIPTS_LENGTH);
+ return t;
+}
+# endif /* NUM_SCRIPTS > 0 */
+
+#endif /* defined(SINGLE_APPLET_MAIN) */
#if ENABLE_BUILD_LIBBUSYBOX
config SH_IS_ASH
depends on !NOMMU
bool "ash"
+ select SHELL_ASH
help
Choose ash to be the shell executed by 'sh' name.
The ash code will be built into busybox. If you don't select
config SH_IS_HUSH
bool "hush"
+ select SHELL_HUSH
help
Choose hush to be the shell executed by 'sh' name.
The hush code will be built into busybox. If you don't select
config BASH_IS_ASH
depends on !NOMMU
bool "ash"
+ select SHELL_ASH
help
Choose ash to be the shell executed by 'bash' name.
The ash code will be built into busybox. If you don't select
config BASH_IS_HUSH
bool "hush"
+ select SHELL_HUSH
help
Choose hush to be the shell executed by 'bash' name.
The hush code will be built into busybox. If you don't select
comment "Options common to all shells"
-if ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+if SHELL_ASH || SHELL_HUSH
config FEATURE_SH_MATH
bool "POSIX math support"
default y
- depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+ depends on SHELL_ASH || SHELL_HUSH
help
Enable math support in the shell via $((...)) syntax.
config FEATURE_SH_EXTRA_QUIET
bool "Hide message on interactive shell startup"
default y
- depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+ depends on SHELL_ASH || SHELL_HUSH
help
Remove the busybox introduction when starting a shell.
config FEATURE_SH_STANDALONE
bool "Standalone shell"
default n
- depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+ depends on SHELL_ASH || SHELL_HUSH
help
This option causes busybox shells to use busybox applets
in preference to executables in the PATH whenever possible. For
config FEATURE_SH_NOFORK
bool "Run 'nofork' applets directly"
default n
- depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+ depends on SHELL_ASH || SHELL_HUSH
help
This option causes busybox shells to not execute typical
fork/exec/wait sequence, but call <applet>_main directly,
config FEATURE_SH_READ_FRAC
bool "read -t N.NNN support (+110 bytes)"
default y
- depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+ depends on SHELL_ASH || SHELL_HUSH
help
Enable support for fractional second timeout in read builtin.
config FEATURE_SH_HISTFILESIZE
bool "Use $HISTFILESIZE"
default y
- depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+ depends on SHELL_ASH || SHELL_HUSH
help
This option makes busybox shells to use $HISTFILESIZE variable
to set shell history size. Note that its max value is capped
config FEATURE_SH_EMBEDDED_SCRIPTS
bool "Embed scripts in the binary"
default y
- depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
+ depends on SHELL_ASH || SHELL_HUSH
help
Allow scripts to be compressed and embedded in the busybox
binary. The scripts should be placed in the 'embed' directory
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
+//config:config SHELL_ASH
+//config: bool #hidden option
+//config: depends on !NOMMU
+//config:
//config:config ASH
//config: bool "ash (78 kb)"
//config: default y
//config: depends on !NOMMU
+//config: select SHELL_ASH
//config: help
//config: The most complete and most pedantically correct shell included with
//config: busybox. This shell is actually a derivative of the Debian 'dash'
//config:# ash options
//config:# note: Don't remove !NOMMU part in the next line; it would break
//config:# menuconfig's indenting.
-//config:if !NOMMU && (ASH || SH_IS_ASH || BASH_IS_ASH)
+//config:if !NOMMU && (SHELL_ASH || ASH || SH_IS_ASH || BASH_IS_ASH)
//config:
//config:config ASH_OPTIMIZE_FOR_SIZE
//config: bool "Optimize for size instead of speed"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_INTERNAL_GLOB
//config: bool "Use internal glob() implementation"
//config: default y # Y is bigger, but because of uclibc glob() bug, let Y be default for now
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config: help
//config: Do not use glob() function from libc, use internal implementation.
//config: Use this if you are getting "glob.h: No such file or directory"
//config:config ASH_BASH_COMPAT
//config: bool "bash-compatible extensions"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_BASH_SOURCE_CURDIR
//config: bool "'source' and '.' builtins search current directory after $PATH"
//config:config ASH_JOB_CONTROL
//config: bool "Job control"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_ALIAS
//config: bool "Alias support"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_RANDOM_SUPPORT
//config: bool "Pseudorandom generator and $RANDOM variable"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config: help
//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
//config: Each read of "$RANDOM" will generate a new pseudorandom value.
//config:config ASH_EXPAND_PRMT
//config: bool "Expand prompt string"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config: help
//config: $PS# may contain volatile content, such as backquote commands.
//config: This option recreates the prompt string from the environment
//config:config ASH_IDLE_TIMEOUT
//config: bool "Idle timeout variable $TMOUT"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config: help
//config: Enable bash-like auto-logout after $TMOUT seconds of idle time.
//config:
//config:config ASH_MAIL
//config: bool "Check for new mail in interactive shell"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config: help
//config: Enable "check for new mail" function:
//config: if set, $MAIL file and $MAILPATH list of files
//config:config ASH_ECHO
//config: bool "echo builtin"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_PRINTF
//config: bool "printf builtin"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_TEST
//config: bool "test builtin"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_HELP
//config: bool "help builtin"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_GETOPTS
//config: bool "getopts builtin"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config:
//config:config ASH_CMDCMD
//config: bool "command builtin"
//config: default y
-//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
+//config: depends on SHELL_ASH
//config: help
//config: Enable support for the 'command' builtin, which allows
//config: you to run the specified command or builtin,
//applet:IF_SH_IS_ASH( APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash))
//applet:IF_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, ash))
-//kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o
-//kbuild:lib-$(CONFIG_SH_IS_ASH) += ash.o ash_ptr_hack.o shell_common.o
-//kbuild:lib-$(CONFIG_BASH_IS_ASH) += ash.o ash_ptr_hack.o shell_common.o
+//kbuild:lib-$(CONFIG_SHELL_ASH) += ash.o ash_ptr_hack.o shell_common.o
//kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o
/*
//config:config HUSH
//config: bool "hush (68 kb)"
//config: default y
+//config: select SHELL_HUSH
//config: help
//config: hush is a small shell. It handles the normal flow control
//config: constructs such as if/then/elif/else/fi, for/in/do/done, while loops,
//config: It does not handle select, aliases, tilde expansion,
//config: &>file and >&file redirection of stdout+stderr.
//config:
+// This option is visible (has a description) to make it possible to select
+// a "scripted" applet (such as NOLOGIN) but avoid selecting any shells:
+//config:config SHELL_HUSH
+//config: bool "Internal shell for embedded script support"
+//config: default n
+//config:
+//config:# hush options
+//config:# It's only needed to get "nice" menuconfig indenting.
+//config:if SHELL_HUSH || HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config:
//config:config HUSH_BASH_COMPAT
//config: bool "bash-compatible extensions"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_BRACE_EXPANSION
//config: bool "Brace expansion"
//config:config HUSH_INTERACTIVE
//config: bool "Interactive mode"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config: help
//config: Enable interactive mode (prompt and command editing).
//config: Without this, hush simply reads and executes commands
//config:config HUSH_TICK
//config: bool "Support command substitution"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config: help
//config: Enable `command` and $(command).
//config:
//config:config HUSH_IF
//config: bool "Support if/then/elif/else/fi"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_LOOPS
//config: bool "Support for, while and until loops"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_CASE
//config: bool "Support case ... esac statement"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config: help
//config: Enable case ... esac statement. +400 bytes.
//config:
//config:config HUSH_FUNCTIONS
//config: bool "Support funcname() { commands; } syntax"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config: help
//config: Enable support for shell functions. +800 bytes.
//config:
//config:config HUSH_RANDOM_SUPPORT
//config: bool "Pseudorandom generator and $RANDOM variable"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config: help
//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
//config: Each read of "$RANDOM" will generate a new pseudorandom value.
//config:config HUSH_MODE_X
//config: bool "Support 'hush -x' option and 'set -x' command"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config: help
//config: This instructs hush to print commands before execution.
//config: Adds ~300 bytes.
//config:config HUSH_ECHO
//config: bool "echo builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_PRINTF
//config: bool "printf builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_TEST
//config: bool "test builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_HELP
//config: bool "help builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_EXPORT
//config: bool "export builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_EXPORT_N
//config: bool "Support 'export -n' option"
//config:config HUSH_READONLY
//config: bool "readonly builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config: help
//config: Enable support for read-only variables.
//config:
//config:config HUSH_KILL
//config: bool "kill builtin (supports kill %jobspec)"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_WAIT
//config: bool "wait builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_COMMAND
//config: bool "command builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_TRAP
//config: bool "trap builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_TYPE
//config: bool "type builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_TIMES
//config: bool "times builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_READ
//config: bool "read builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_SET
//config: bool "set builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_UNSET
//config: bool "unset builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_ULIMIT
//config: bool "ulimit builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_UMASK
//config: bool "umask builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_GETOPTS
//config: bool "getopts builtin"
//config: default y
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
//config:
//config:config HUSH_MEMLEAK
//config: bool "memleak builtin (debugging)"
//config: default n
-//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
+//config: depends on SHELL_HUSH
+//config:
+//config:endif # hush options
//applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP))
// APPLET_ODDNAME:name main location suid_type help
//applet:IF_SH_IS_HUSH( APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
//applet:IF_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
-//kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o
-//kbuild:lib-$(CONFIG_SH_IS_HUSH) += hush.o match.o shell_common.o
-//kbuild:lib-$(CONFIG_BASH_IS_HUSH) += hush.o match.o shell_common.o
+//kbuild:lib-$(CONFIG_SHELL_HUSH) += hush.o match.o shell_common.o
//kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o
/* -i (interactive) is also accepted,
//config:
//config:config NOLOGIN_DEPENDENCIES
//config: bool "Enable dependencies for nologin"
-//config: default y
+//config: default n # Y default makes it harder to select single-applet test
//config: depends on NOLOGIN
//config: select CAT
//config: select ECHO