Make it possible to select "sh" and "bash" aliases without selecting ash or hush
The same can be done for msh, but we are probably better off just deleting it in a next versio or two. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
04c1a2a2c4
commit
0b8835861b
@ -10,12 +10,16 @@ lib-y:=
|
||||
|
||||
INSERT
|
||||
|
||||
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
|
||||
lib-$(CONFIG_LESS) += cat.o # less too
|
||||
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
|
||||
lib-$(CONFIG_ADDUSER) += chown.o # used by adduser
|
||||
lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser
|
||||
lib-$(CONFIG_ASH) += echo.o # used by ash
|
||||
lib-$(CONFIG_HUSH) += echo.o # used by hush
|
||||
lib-$(CONFIG_FTPD) += ls.o # used by ftpd
|
||||
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
|
||||
lib-$(CONFIG_LESS) += cat.o # less too
|
||||
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
|
||||
lib-$(CONFIG_ADDUSER) += chown.o # used by adduser
|
||||
lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser
|
||||
lib-$(CONFIG_ASH) += echo.o # used by ash
|
||||
lib-$(CONFIG_SH_IS_ASH) += echo.o # used by ash
|
||||
lib-$(CONFIG_BASH_IS_ASH) += echo.o # used by ash
|
||||
lib-$(CONFIG_HUSH) += echo.o # used by hush
|
||||
lib-$(CONFIG_SH_IS_HUSH) += echo.o # used by hush
|
||||
lib-$(CONFIG_BASH_IS_HUSH) += echo.o # used by hush
|
||||
lib-$(CONFIG_FTPD) += ls.o # used by ftpd
|
||||
lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o
|
||||
|
@ -55,6 +55,8 @@
|
||||
//kbuild:lib-$(CONFIG_TEST2) += test.o test_ptr_hack.o
|
||||
//kbuild:lib-$(CONFIG_ASH_BUILTIN_TEST) += test.o test_ptr_hack.o
|
||||
//kbuild:lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o
|
||||
//kbuild:lib-$(CONFIG_SH_IS_HUSH) += test.o test_ptr_hack.o
|
||||
//kbuild:lib-$(CONFIG_BASH_IS_HUSH) += test.o test_ptr_hack.o
|
||||
|
||||
/* "test --help" is special-cased to ignore --help */
|
||||
//usage:#define test_trivial_usage NOUSAGE_STR
|
||||
|
@ -26,6 +26,7 @@ allno="$cfg"
|
||||
for app in $apps; do
|
||||
allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`"
|
||||
done
|
||||
#echo "$allno" >.config_allno
|
||||
|
||||
# Turn on each applet individually and build single-applet executable
|
||||
fail=0
|
||||
@ -37,6 +38,16 @@ for app in $apps; do
|
||||
mv .config .config.SV
|
||||
echo "CONFIG_${app}=y" >.config
|
||||
echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.config
|
||||
|
||||
if test x"${app}" != x"SH_IS_ASH"; then
|
||||
# $allno has all choices for "sh" aliasing at off.
|
||||
# "sh" aliasing defaults to "ash", not none.
|
||||
# without this fix, "make oldconfig" sets it wrong,
|
||||
# resulting in NUM_APPLETS = 2
|
||||
sed '/CONFIG_SH_IS_NONE/d' -i .config
|
||||
echo "CONFIG_SH_IS_NONE=y" >>.config
|
||||
fi
|
||||
|
||||
if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then
|
||||
: $((fail++))
|
||||
echo "Config error for ${app}"
|
||||
|
@ -9,3 +9,5 @@ lib-y:=
|
||||
INSERT
|
||||
|
||||
lib-$(CONFIG_ASH) += kill.o # used for built-in kill by ash
|
||||
lib-$(CONFIG_SH_IS_ASH) += kill.o # used for built-in kill by ash
|
||||
lib-$(CONFIG_BASH_IS_ASH) += kill.o # used for built-in kill by ash
|
||||
|
@ -5,34 +5,30 @@
|
||||
|
||||
menu "Shells"
|
||||
|
||||
INSERT
|
||||
|
||||
|
||||
choice
|
||||
prompt "Choose which shell is aliased to 'sh' name"
|
||||
default FEATURE_SH_IS_ASH
|
||||
default SH_IS_ASH
|
||||
help
|
||||
Choose which shell you want to be executed by 'sh' alias.
|
||||
The ash shell is the most bash compatible and full featured one.
|
||||
|
||||
# note: cannot use "select ASH" here, it breaks "make allnoconfig"
|
||||
config FEATURE_SH_IS_ASH
|
||||
depends on ASH
|
||||
bool "ash"
|
||||
config SH_IS_ASH
|
||||
depends on !NOMMU
|
||||
bool "ash"
|
||||
|
||||
config FEATURE_SH_IS_HUSH
|
||||
depends on HUSH
|
||||
config SH_IS_HUSH
|
||||
bool "hush"
|
||||
|
||||
config FEATURE_SH_IS_NONE
|
||||
config SH_IS_NONE
|
||||
bool "none"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Choose which shell is aliased to 'bash' name"
|
||||
default FEATURE_BASH_IS_NONE
|
||||
default BASH_IS_NONE
|
||||
help
|
||||
Choose which shell you want to be executed by 'bash' alias.
|
||||
The ash shell is the most bash compatible and full featured one.
|
||||
@ -47,32 +43,33 @@ choice
|
||||
can't be used for running them because it won't recongnize
|
||||
"bash" as a supported applet name.
|
||||
|
||||
config FEATURE_BASH_IS_ASH
|
||||
depends on ASH
|
||||
bool "ash"
|
||||
config BASH_IS_ASH
|
||||
depends on !NOMMU
|
||||
bool "ash"
|
||||
|
||||
config FEATURE_BASH_IS_HUSH
|
||||
depends on HUSH
|
||||
config BASH_IS_HUSH
|
||||
bool "hush"
|
||||
|
||||
config FEATURE_BASH_IS_NONE
|
||||
config BASH_IS_NONE
|
||||
bool "none"
|
||||
|
||||
endchoice
|
||||
|
||||
|
||||
config SH_MATH_SUPPORT
|
||||
INSERT
|
||||
|
||||
|
||||
config FEATURE_SH_MATH
|
||||
bool "POSIX math support"
|
||||
default y
|
||||
depends on ASH || HUSH
|
||||
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
help
|
||||
Enable math support in the shell via $((...)) syntax.
|
||||
|
||||
config SH_MATH_SUPPORT_64
|
||||
config FEATURE_SH_MATH_64
|
||||
bool "Extend POSIX math support to 64 bit"
|
||||
default y
|
||||
depends on SH_MATH_SUPPORT
|
||||
depends on FEATURE_SH_MATH
|
||||
help
|
||||
Enable 64-bit math support in the shell. This will make the shell
|
||||
slightly larger, but will allow computation with very large numbers.
|
||||
@ -81,14 +78,14 @@ config SH_MATH_SUPPORT_64
|
||||
config FEATURE_SH_EXTRA_QUIET
|
||||
bool "Hide message on interactive shell startup"
|
||||
default y
|
||||
depends on HUSH || ASH
|
||||
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
help
|
||||
Remove the busybox introduction when starting a shell.
|
||||
|
||||
config FEATURE_SH_STANDALONE
|
||||
bool "Standalone shell"
|
||||
default n
|
||||
depends on (HUSH || ASH)
|
||||
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
help
|
||||
This option causes busybox shells to use busybox applets
|
||||
in preference to executables in the PATH whenever possible. For
|
||||
@ -121,7 +118,7 @@ config FEATURE_SH_STANDALONE
|
||||
config FEATURE_SH_NOFORK
|
||||
bool "Run 'nofork' applets directly"
|
||||
default n
|
||||
depends on (HUSH || ASH)
|
||||
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
help
|
||||
This option causes busybox shells to not execute typical
|
||||
fork/exec/wait sequence, but call <applet>_main directly,
|
||||
@ -139,7 +136,7 @@ config FEATURE_SH_NOFORK
|
||||
config FEATURE_SH_HISTFILESIZE
|
||||
bool "Use $HISTFILESIZE"
|
||||
default y
|
||||
depends on HUSH || ASH
|
||||
depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
help
|
||||
This option makes busybox shells to use $HISTFILESIZE variable
|
||||
to set shell history size. Note that its max value is capped
|
||||
|
@ -8,4 +8,4 @@ lib-y:=
|
||||
|
||||
INSERT
|
||||
|
||||
lib-$(CONFIG_SH_MATH_SUPPORT) += math.o
|
||||
lib-$(CONFIG_FEATURE_SH_MATH) += math.o
|
||||
|
95
shell/ash.c
95
shell/ash.c
@ -29,14 +29,14 @@
|
||||
//config:config ASH_OPTIMIZE_FOR_SIZE
|
||||
//config: bool "Optimize for size instead of speed"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Compile ash for reduced size at the price of speed.
|
||||
//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
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_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"
|
||||
@ -45,7 +45,7 @@
|
||||
//config:config ASH_RANDOM_SUPPORT
|
||||
//config: bool "Pseudorandom generator and $RANDOM variable"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
|
||||
//config: Each read of "$RANDOM" will generate a new pseudorandom value.
|
||||
@ -56,7 +56,7 @@
|
||||
//config:config ASH_EXPAND_PRMT
|
||||
//config: bool "Expand prompt string"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: "PS#" may contain volatile content, such as backquote commands.
|
||||
//config: This option recreates the prompt string from the environment
|
||||
@ -65,70 +65,70 @@
|
||||
//config:config ASH_BASH_COMPAT
|
||||
//config: bool "bash-compatible extensions"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable bash-compatible extensions.
|
||||
//config:
|
||||
//config:config ASH_IDLE_TIMEOUT
|
||||
//config: bool "Idle timeout variable"
|
||||
//config: default n
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enables bash-like auto-logout after $TMOUT seconds of idle time.
|
||||
//config:
|
||||
//config:config ASH_JOB_CONTROL
|
||||
//config: bool "Job control"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable job control in the ash shell.
|
||||
//config:
|
||||
//config:config ASH_ALIAS
|
||||
//config: bool "Alias support"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable alias support in the ash shell.
|
||||
//config:
|
||||
//config:config ASH_GETOPTS
|
||||
//config: bool "Builtin getopt to parse positional parameters"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable support for getopts builtin in ash.
|
||||
//config:
|
||||
//config:config ASH_BUILTIN_ECHO
|
||||
//config: bool "Builtin version of 'echo'"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable support for echo builtin in ash.
|
||||
//config:
|
||||
//config:config ASH_BUILTIN_PRINTF
|
||||
//config: bool "Builtin version of 'printf'"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable support for printf builtin in ash.
|
||||
//config:
|
||||
//config:config ASH_BUILTIN_TEST
|
||||
//config: bool "Builtin version of 'test'"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable support for test builtin in ash.
|
||||
//config:
|
||||
//config:config ASH_HELP
|
||||
//config: bool "help builtin"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable help builtin in ash.
|
||||
//config:
|
||||
//config:config ASH_CMDCMD
|
||||
//config: bool "'command' command to override shell builtins"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable support for the ash 'command' builtin, which allows
|
||||
//config: you to run the specified command with the specified arguments,
|
||||
@ -137,15 +137,17 @@
|
||||
//config:config ASH_MAIL
|
||||
//config: bool "Check for new mail on interactive shells"
|
||||
//config: default y
|
||||
//config: depends on ASH
|
||||
//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
|
||||
//config: help
|
||||
//config: Enable "check for new mail" function in the ash shell.
|
||||
|
||||
//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh))
|
||||
//applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash))
|
||||
//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_ASH_RANDOM_SUPPORT) += random.o
|
||||
|
||||
/*
|
||||
@ -200,7 +202,7 @@
|
||||
|
||||
#include "unicode.h"
|
||||
#include "shell_common.h"
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
# include "math.h"
|
||||
#endif
|
||||
#if ENABLE_ASH_RANDOM_SUPPORT
|
||||
@ -2144,6 +2146,7 @@ lookupvar(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if ENABLE_UNICODE_SUPPORT
|
||||
static void
|
||||
reinit_unicode_for_ash(void)
|
||||
{
|
||||
@ -2160,6 +2163,9 @@ reinit_unicode_for_ash(void)
|
||||
reinit_unicode(s);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define reinit_unicode_for_ash() ((void)0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Search the environment of a builtin command.
|
||||
@ -2741,7 +2747,7 @@ pwdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
|
||||
#define USE_SIT_FUNCTION ENABLE_ASH_OPTIMIZE_FOR_SIZE
|
||||
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
# define SIT_ITEM(a,b,c,d) (a | (b << 4) | (c << 8) | (d << 12))
|
||||
#else
|
||||
# define SIT_ITEM(a,b,c,d) (a | (b << 4) | (c << 8))
|
||||
@ -3129,7 +3135,7 @@ static const uint8_t syntax_index_table[] ALIGN1 = {
|
||||
({ \
|
||||
if ((c) < 0 || (c) > (PEOF + ENABLE_ASH_ALIAS)) \
|
||||
bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \
|
||||
if ((syntax) < 0 || (syntax) > (2 + ENABLE_SH_MATH_SUPPORT)) \
|
||||
if ((syntax) < 0 || (syntax) > (2 + ENABLE_FEATURE_SH_MATH)) \
|
||||
bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \
|
||||
((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf); \
|
||||
})
|
||||
@ -4487,7 +4493,7 @@ cmdputs(const char *s)
|
||||
case CTLBACKQ:
|
||||
str = "$(...)";
|
||||
goto dostr;
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
case CTLARI:
|
||||
str = "$((";
|
||||
goto dostr;
|
||||
@ -5547,7 +5553,7 @@ redirectsafe(union node *redir, int flags)
|
||||
* We have to deal with backquotes, shell variables, and file metacharacters.
|
||||
*/
|
||||
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
static arith_t
|
||||
ash_arith(const char *s)
|
||||
{
|
||||
@ -5635,7 +5641,7 @@ static struct arglist exparg;
|
||||
/*
|
||||
* Our own itoa().
|
||||
*/
|
||||
#if !ENABLE_SH_MATH_SUPPORT
|
||||
#if !ENABLE_FEATURE_SH_MATH
|
||||
/* cvtnum() is used even if math support is off (to prepare $? values and such) */
|
||||
typedef long arith_t;
|
||||
# define ARITH_FMT "%ld"
|
||||
@ -6148,7 +6154,7 @@ expbackq(union node *cmd, int flag)
|
||||
stackblock() + startloc));
|
||||
}
|
||||
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
/*
|
||||
* Expand arithmetic expression. Backup to start of expression,
|
||||
* evaluate, place result in (backed up) result, adjust string position.
|
||||
@ -6230,7 +6236,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
|
||||
CTLESC,
|
||||
CTLVAR,
|
||||
CTLBACKQ,
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
CTLENDARI,
|
||||
#endif
|
||||
'\0'
|
||||
@ -6266,7 +6272,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
|
||||
c = p[length];
|
||||
if (c) {
|
||||
if (!(c & 0x80)
|
||||
IF_SH_MATH_SUPPORT(|| c == CTLENDARI)
|
||||
IF_FEATURE_SH_MATH(|| c == CTLENDARI)
|
||||
) {
|
||||
/* c == '=' || c == ':' || c == CTLENDARI */
|
||||
length++;
|
||||
@ -6346,7 +6352,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
|
||||
expbackq(argbackq->n, flags | inquotes);
|
||||
argbackq = argbackq->next;
|
||||
goto start;
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
case CTLENDARI:
|
||||
p--;
|
||||
expari(flags | inquotes);
|
||||
@ -9265,7 +9271,7 @@ static int helpcmd(int, char **) FAST_FUNC;
|
||||
#if MAX_HISTORY
|
||||
static int historycmd(int, char **) FAST_FUNC;
|
||||
#endif
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
static int letcmd(int, char **) FAST_FUNC;
|
||||
#endif
|
||||
static int readcmd(int, char **) FAST_FUNC;
|
||||
@ -9345,7 +9351,7 @@ static const struct builtincmd builtintab[] = {
|
||||
{ BUILTIN_REGULAR "jobs" , jobscmd },
|
||||
{ BUILTIN_REGULAR "kill" , killcmd },
|
||||
#endif
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
{ BUILTIN_NOSPEC "let" , letcmd },
|
||||
#endif
|
||||
{ BUILTIN_ASSIGN "local" , localcmd },
|
||||
@ -11394,13 +11400,13 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
|
||||
smallint quotef;
|
||||
smallint dblquote;
|
||||
smallint oldstyle;
|
||||
IF_SH_MATH_SUPPORT(smallint prevsyntax;) /* syntax before arithmetic */
|
||||
IF_FEATURE_SH_MATH(smallint prevsyntax;) /* syntax before arithmetic */
|
||||
#if ENABLE_ASH_EXPAND_PRMT
|
||||
smallint pssyntax; /* we are expanding a prompt string */
|
||||
#endif
|
||||
int varnest; /* levels of variables expansion */
|
||||
IF_SH_MATH_SUPPORT(int arinest;) /* levels of arithmetic expansion */
|
||||
IF_SH_MATH_SUPPORT(int parenlevel;) /* levels of parens in arithmetic */
|
||||
IF_FEATURE_SH_MATH(int arinest;) /* levels of arithmetic expansion */
|
||||
IF_FEATURE_SH_MATH(int parenlevel;) /* levels of parens in arithmetic */
|
||||
int dqvarnest; /* levels of variables expansion within double quotes */
|
||||
|
||||
IF_ASH_BASH_COMPAT(smallint bash_dollar_squote = 0;)
|
||||
@ -11408,7 +11414,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
|
||||
startlinno = g_parsefile->linno;
|
||||
bqlist = NULL;
|
||||
quotef = 0;
|
||||
IF_SH_MATH_SUPPORT(prevsyntax = 0;)
|
||||
IF_FEATURE_SH_MATH(prevsyntax = 0;)
|
||||
#if ENABLE_ASH_EXPAND_PRMT
|
||||
pssyntax = (syntax == PSSYNTAX);
|
||||
if (pssyntax)
|
||||
@ -11416,8 +11422,8 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
|
||||
#endif
|
||||
dblquote = (syntax == DQSYNTAX);
|
||||
varnest = 0;
|
||||
IF_SH_MATH_SUPPORT(arinest = 0;)
|
||||
IF_SH_MATH_SUPPORT(parenlevel = 0;)
|
||||
IF_FEATURE_SH_MATH(arinest = 0;)
|
||||
IF_FEATURE_SH_MATH(parenlevel = 0;)
|
||||
dqvarnest = 0;
|
||||
|
||||
STARTSTACKSTR(out);
|
||||
@ -11524,7 +11530,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
|
||||
}
|
||||
USTPUTC(c, out);
|
||||
break;
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
case CLP: /* '(' in arithmetic */
|
||||
parenlevel++;
|
||||
USTPUTC(c, out);
|
||||
@ -11575,7 +11581,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
|
||||
} /* for (;;) */
|
||||
endword:
|
||||
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
if (syntax == ARISYNTAX)
|
||||
raise_error_syntax("missing '))'");
|
||||
#endif
|
||||
@ -11754,7 +11760,7 @@ parsesub: {
|
||||
} else if (c == '(') {
|
||||
/* $(command) or $((arith)) */
|
||||
if (pgetc_eatbnl() == '(') {
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
PARSEARITH();
|
||||
#else
|
||||
raise_error_syntax("you disabled math support for $((arith)) syntax");
|
||||
@ -12009,7 +12015,7 @@ parsebackq: {
|
||||
goto parsebackq_newreturn;
|
||||
}
|
||||
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
/*
|
||||
* Parse an arithmetic expansion (indicate start of one and set state)
|
||||
*/
|
||||
@ -13046,7 +13052,7 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
/*
|
||||
* The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell.
|
||||
* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
@ -13301,15 +13307,6 @@ init(void)
|
||||
//usage:#define ash_full_usage "\n\n"
|
||||
//usage: "Unix shell interpreter"
|
||||
|
||||
//usage:#if ENABLE_FEATURE_SH_IS_ASH
|
||||
//usage:# define sh_trivial_usage ash_trivial_usage
|
||||
//usage:# define sh_full_usage ash_full_usage
|
||||
//usage:#endif
|
||||
//usage:#if ENABLE_FEATURE_BASH_IS_ASH
|
||||
//usage:# define bash_trivial_usage ash_trivial_usage
|
||||
//usage:# define bash_full_usage ash_full_usage
|
||||
//usage:#endif
|
||||
|
||||
/*
|
||||
* Process the shell command line arguments.
|
||||
*/
|
||||
|
59
shell/hush.c
59
shell/hush.c
@ -99,7 +99,7 @@
|
||||
//config:config HUSH_BASH_COMPAT
|
||||
//config: bool "bash-compatible extensions"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable bash-compatible extensions.
|
||||
//config:
|
||||
@ -113,14 +113,14 @@
|
||||
//config:config HUSH_HELP
|
||||
//config: bool "help builtin"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable help builtin in hush. Code size + ~1 kbyte.
|
||||
//config:
|
||||
//config:config HUSH_INTERACTIVE
|
||||
//config: bool "Interactive mode"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable interactive mode (prompt and command editing).
|
||||
//config: Without this, hush simply reads and executes commands
|
||||
@ -148,35 +148,35 @@
|
||||
//config:config HUSH_TICK
|
||||
//config: bool "Process substitution"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable process substitution `command` and $(command) in hush.
|
||||
//config:
|
||||
//config:config HUSH_IF
|
||||
//config: bool "Support if/then/elif/else/fi"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable if/then/elif/else/fi in hush.
|
||||
//config:
|
||||
//config:config HUSH_LOOPS
|
||||
//config: bool "Support for, while and until loops"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable for, while and until loops in hush.
|
||||
//config:
|
||||
//config:config HUSH_CASE
|
||||
//config: bool "Support case ... esac statement"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable case ... esac statement in hush. +400 bytes.
|
||||
//config:
|
||||
//config:config HUSH_FUNCTIONS
|
||||
//config: bool "Support funcname() { commands; } syntax"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable support for shell functions in hush. +800 bytes.
|
||||
//config:
|
||||
@ -190,7 +190,7 @@
|
||||
//config:config HUSH_RANDOM_SUPPORT
|
||||
//config: bool "Pseudorandom generator and $RANDOM variable"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: Enable pseudorandom generator and dynamic variable "$RANDOM".
|
||||
//config: Each read of "$RANDOM" will generate a new pseudorandom value.
|
||||
@ -198,14 +198,14 @@
|
||||
//config:config HUSH_EXPORT_N
|
||||
//config: bool "Support 'export -n' option"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: export -n unexports variables. It is a bash extension.
|
||||
//config:
|
||||
//config:config HUSH_MODE_X
|
||||
//config: bool "Support 'hush -x' option and 'set -x' command"
|
||||
//config: default y
|
||||
//config: depends on HUSH
|
||||
//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
|
||||
//config: help
|
||||
//config: This instructs hush to print commands before execution.
|
||||
//config: Adds ~300 bytes.
|
||||
@ -216,14 +216,15 @@
|
||||
//config: select HUSH
|
||||
//config: help
|
||||
//config: msh is deprecated and will be removed, please migrate to hush.
|
||||
//config:
|
||||
|
||||
//applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_MSH(APPLET(msh, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, sh))
|
||||
//applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, bash))
|
||||
//applet:IF_MSH(APPLET_ODDNAME(msh, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
|
||||
//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_HUSH_RANDOM_SUPPORT) += random.o
|
||||
|
||||
/* -i (interactive) and -s (read stdin) are also accepted,
|
||||
@ -236,18 +237,6 @@
|
||||
//usage:#define hush_full_usage "\n\n"
|
||||
//usage: "Unix shell interpreter"
|
||||
|
||||
//usage:#define msh_trivial_usage hush_trivial_usage
|
||||
//usage:#define msh_full_usage hush_full_usage
|
||||
|
||||
//usage:#if ENABLE_FEATURE_SH_IS_HUSH
|
||||
//usage:# define sh_trivial_usage hush_trivial_usage
|
||||
//usage:# define sh_full_usage hush_full_usage
|
||||
//usage:#endif
|
||||
//usage:#if ENABLE_FEATURE_BASH_IS_HUSH
|
||||
//usage:# define bash_trivial_usage hush_trivial_usage
|
||||
//usage:# define bash_full_usage hush_full_usage
|
||||
//usage:#endif
|
||||
|
||||
#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
|
||||
|| defined(__APPLE__) \
|
||||
)
|
||||
@ -4011,7 +4000,7 @@ static int i_peek_and_eat_bkslash_nl(struct in_str *input)
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_HUSH_TICK || ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_DOLLAR_OPS
|
||||
#if ENABLE_HUSH_TICK || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_DOLLAR_OPS
|
||||
/* Subroutines for copying $(...) and `...` things */
|
||||
static int add_till_backquote(o_string *dest, struct in_str *input, int in_dquote);
|
||||
/* '...' */
|
||||
@ -4179,7 +4168,7 @@ static int add_till_closing_bracket(o_string *dest, struct in_str *input, unsign
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
#endif /* ENABLE_HUSH_TICK || ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_DOLLAR_OPS */
|
||||
#endif /* ENABLE_HUSH_TICK || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_DOLLAR_OPS */
|
||||
|
||||
/* Return code: 0 for OK, 1 for syntax error */
|
||||
#if BB_MMU
|
||||
@ -4333,13 +4322,13 @@ static int parse_dollar(o_string *as_string,
|
||||
o_addchr(dest, SPECIAL_VAR_SYMBOL);
|
||||
break;
|
||||
}
|
||||
#if ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_TICK
|
||||
#if ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_TICK
|
||||
case '(': {
|
||||
unsigned pos;
|
||||
|
||||
ch = i_getch(input);
|
||||
nommu_addchr(as_string, ch);
|
||||
# if ENABLE_SH_MATH_SUPPORT
|
||||
# if ENABLE_FEATURE_SH_MATH
|
||||
if (i_peek_and_eat_bkslash_nl(input) == '(') {
|
||||
ch = i_getch(input);
|
||||
nommu_addchr(as_string, ch);
|
||||
@ -5217,7 +5206,7 @@ static char *encode_then_expand_string(const char *str, int process_bkslash, int
|
||||
return exp_str;
|
||||
}
|
||||
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
static arith_t expand_and_evaluate_arith(const char *arg, const char **errmsg_p)
|
||||
{
|
||||
arith_state_t math_state;
|
||||
@ -5469,7 +5458,7 @@ static NOINLINE const char *expand_one_var(char **to_be_freed_pp, char *arg, cha
|
||||
}
|
||||
#endif
|
||||
else if (exp_op == ':') {
|
||||
#if ENABLE_HUSH_BASH_COMPAT && ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_HUSH_BASH_COMPAT && ENABLE_FEATURE_SH_MATH
|
||||
/* It's ${var:N[:M]} bashism.
|
||||
* Note that in encoded form it has TWO parts:
|
||||
* var:N<SPECIAL_VAR_SYMBOL>M<SPECIAL_VAR_SYMBOL>
|
||||
@ -5604,7 +5593,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
|
||||
#if ENABLE_HUSH_TICK
|
||||
o_string subst_result = NULL_O_STRING;
|
||||
#endif
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
char arith_buf[sizeof(arith_t)*3 + 2];
|
||||
#endif
|
||||
|
||||
@ -5698,7 +5687,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
|
||||
val = subst_result.data;
|
||||
goto store_val;
|
||||
#endif
|
||||
#if ENABLE_SH_MATH_SUPPORT
|
||||
#if ENABLE_FEATURE_SH_MATH
|
||||
case '+': { /* <SPECIAL_VAR_SYMBOL>+cmd<SPECIAL_VAR_SYMBOL> */
|
||||
arith_t res;
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
|
||||
|
||||
#if ENABLE_SH_MATH_SUPPORT_64
|
||||
#if ENABLE_FEATURE_SH_MATH_64
|
||||
typedef long long arith_t;
|
||||
#define ARITH_FMT "%lld"
|
||||
#define strto_arith_t strtoull
|
||||
|
Loading…
Reference in New Issue
Block a user