aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-11-27 14:34:25 +0000
committerDenys Vlasenko <vda.linux@googlemail.com>2018-11-27 16:13:07 +0100
commit71df2d3589e3e682cd6770f41f0b184841b78702 (patch)
tree0c71963e9d622bc48256a3917c1ce55ccc019a4f /shell/hush.c
parentf4709d78cb0c4f54283046e8f86edb9ecd7e41ca (diff)
downloadbusybox-w32-71df2d3589e3e682cd6770f41f0b184841b78702.tar.gz
busybox-w32-71df2d3589e3e682cd6770f41f0b184841b78702.tar.bz2
busybox-w32-71df2d3589e3e682cd6770f41f0b184841b78702.zip
hush: allow hush to run embedded scripts
Embedded scripts require a shell to be present in the BusyBox binary. Allow either ash or hush to be used for this purpose. If both are enabled ash takes precedence. The size of the binary is unchanged in the default configuration: both ash and hush are present but support for embedded scripts isn't compiled into hush. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 431010f09..90191408d 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -367,6 +367,11 @@
367# define PIPE_BUF 4096 /* amount of buffering in a pipe */ 367# define PIPE_BUF 4096 /* amount of buffering in a pipe */
368#endif 368#endif
369 369
370#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !(ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH)
371# include "embedded_scripts.h"
372#else
373# define NUM_SCRIPTS 0
374#endif
370 375
371/* So far, all bash compat is controlled by one config option */ 376/* So far, all bash compat is controlled by one config option */
372/* Separate defines document which part of code implements what */ 377/* Separate defines document which part of code implements what */
@@ -9951,6 +9956,14 @@ int hush_main(int argc, char **argv)
9951 /* http://www.opengroup.org/onlinepubs/9699919799/utilities/sh.html */ 9956 /* http://www.opengroup.org/onlinepubs/9699919799/utilities/sh.html */
9952 flags = (argv[0] && argv[0][0] == '-') ? OPT_login : 0; 9957 flags = (argv[0] && argv[0][0] == '-') ? OPT_login : 0;
9953 builtin_argc = 0; 9958 builtin_argc = 0;
9959#if NUM_SCRIPTS > 0
9960 if (argc < 0) {
9961 optarg = get_script_content(-argc - 1);
9962 optind = 0;
9963 argc = string_array_len(argv);
9964 goto run_script;
9965 }
9966#endif
9954 while (1) { 9967 while (1) {
9955 int opt = getopt(argc, argv, "+c:exinsl" 9968 int opt = getopt(argc, argv, "+c:exinsl"
9956#if !BB_MMU 9969#if !BB_MMU
@@ -9974,6 +9987,9 @@ int hush_main(int argc, char **argv)
9974 * Note: the form without ARG0 never happens: 9987 * Note: the form without ARG0 never happens:
9975 * sh ... -c 'builtin' BARGV... "" 9988 * sh ... -c 'builtin' BARGV... ""
9976 */ 9989 */
9990#if NUM_SCRIPTS > 0
9991 run_script:
9992#endif
9977 if (!G.root_pid) { 9993 if (!G.root_pid) {
9978 G.root_pid = getpid(); 9994 G.root_pid = getpid();
9979 G.root_ppid = getppid(); 9995 G.root_ppid = getppid();