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:
Denys Vlasenko 2016-12-23 16:49:07 +01:00
parent 9982d88a61
commit 28251dfa64
9 changed files with 120 additions and 118 deletions

View File

@ -10,12 +10,16 @@ lib-y:=
INSERT INSERT
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
lib-$(CONFIG_LESS) += cat.o # less too lib-$(CONFIG_LESS) += cat.o # less too
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
lib-$(CONFIG_ADDUSER) += chown.o # used by adduser lib-$(CONFIG_ADDUSER) += chown.o # used by adduser
lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser
lib-$(CONFIG_ASH) += echo.o # used by ash lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_HUSH) += echo.o # used by hush lib-$(CONFIG_SH_IS_ASH) += echo.o # used by ash
lib-$(CONFIG_FTPD) += ls.o # used by ftpd 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 lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o

View File

@ -55,6 +55,8 @@
//kbuild:lib-$(CONFIG_TEST2) += test.o test_ptr_hack.o //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_ASH_BUILTIN_TEST) += test.o test_ptr_hack.o
//kbuild:lib-$(CONFIG_HUSH) += 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 */ /* "test --help" is special-cased to ignore --help */
//usage:#define test_trivial_usage NOUSAGE_STR //usage:#define test_trivial_usage NOUSAGE_STR

View File

@ -26,6 +26,7 @@ allno="$cfg"
for app in $apps; do for app in $apps; do
allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`" allno="`echo "$allno" | sed "s/^CONFIG_${app}=y\$/# CONFIG_${app} is not set/"`"
done done
#echo "$allno" >.config_allno
# Turn on each applet individually and build single-applet executable # Turn on each applet individually and build single-applet executable
fail=0 fail=0
@ -37,6 +38,16 @@ for app in $apps; do
mv .config .config.SV mv .config .config.SV
echo "CONFIG_${app}=y" >.config echo "CONFIG_${app}=y" >.config
echo "$allno" | sed "/^# CONFIG_${app} is not set\$/d" >>.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 if ! yes '' | make oldconfig >busybox_make_${app}.log 2>&1; then
: $((fail++)) : $((fail++))
echo "Config error for ${app}" echo "Config error for ${app}"

View File

@ -9,3 +9,5 @@ lib-y:=
INSERT INSERT
lib-$(CONFIG_ASH) += kill.o # used for built-in kill by ash 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

View File

@ -5,34 +5,30 @@
menu "Shells" menu "Shells"
INSERT
choice choice
prompt "Choose which shell is aliased to 'sh' name" prompt "Choose which shell is aliased to 'sh' name"
default FEATURE_SH_IS_ASH default SH_IS_ASH
help help
Choose which shell you want to be executed by 'sh' alias. Choose which shell you want to be executed by 'sh' alias.
The ash shell is the most bash compatible and full featured one. The ash shell is the most bash compatible and full featured one.
# note: cannot use "select ASH" here, it breaks "make allnoconfig" # note: cannot use "select ASH" here, it breaks "make allnoconfig"
config FEATURE_SH_IS_ASH config SH_IS_ASH
depends on ASH
bool "ash"
depends on !NOMMU depends on !NOMMU
bool "ash"
config FEATURE_SH_IS_HUSH config SH_IS_HUSH
depends on HUSH
bool "hush" bool "hush"
config FEATURE_SH_IS_NONE config SH_IS_NONE
bool "none" bool "none"
endchoice endchoice
choice choice
prompt "Choose which shell is aliased to 'bash' name" prompt "Choose which shell is aliased to 'bash' name"
default FEATURE_BASH_IS_NONE default BASH_IS_NONE
help help
Choose which shell you want to be executed by 'bash' alias. Choose which shell you want to be executed by 'bash' alias.
The ash shell is the most bash compatible and full featured one. 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 can't be used for running them because it won't recongnize
"bash" as a supported applet name. "bash" as a supported applet name.
config FEATURE_BASH_IS_ASH config BASH_IS_ASH
depends on ASH
bool "ash"
depends on !NOMMU depends on !NOMMU
bool "ash"
config FEATURE_BASH_IS_HUSH config BASH_IS_HUSH
depends on HUSH
bool "hush" bool "hush"
config FEATURE_BASH_IS_NONE config BASH_IS_NONE
bool "none" bool "none"
endchoice endchoice
config SH_MATH_SUPPORT INSERT
config FEATURE_SH_MATH
bool "POSIX math support" bool "POSIX math support"
default y default y
depends on ASH || HUSH depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help help
Enable math support in the shell via $((...)) syntax. 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" bool "Extend POSIX math support to 64 bit"
default y default y
depends on SH_MATH_SUPPORT depends on FEATURE_SH_MATH
help help
Enable 64-bit math support in the shell. This will make the shell Enable 64-bit math support in the shell. This will make the shell
slightly larger, but will allow computation with very large numbers. slightly larger, but will allow computation with very large numbers.
@ -81,14 +78,14 @@ config SH_MATH_SUPPORT_64
config FEATURE_SH_EXTRA_QUIET config FEATURE_SH_EXTRA_QUIET
bool "Hide message on interactive shell startup" bool "Hide message on interactive shell startup"
default y default y
depends on HUSH || ASH depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help help
Remove the busybox introduction when starting a shell. Remove the busybox introduction when starting a shell.
config FEATURE_SH_STANDALONE config FEATURE_SH_STANDALONE
bool "Standalone shell" bool "Standalone shell"
default n default n
depends on (HUSH || ASH) depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help help
This option causes busybox shells to use busybox applets This option causes busybox shells to use busybox applets
in preference to executables in the PATH whenever possible. For in preference to executables in the PATH whenever possible. For
@ -121,7 +118,7 @@ config FEATURE_SH_STANDALONE
config FEATURE_SH_NOFORK config FEATURE_SH_NOFORK
bool "Run 'nofork' applets directly" bool "Run 'nofork' applets directly"
default n default n
depends on (HUSH || ASH) depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help help
This option causes busybox shells to not execute typical This option causes busybox shells to not execute typical
fork/exec/wait sequence, but call <applet>_main directly, fork/exec/wait sequence, but call <applet>_main directly,
@ -139,7 +136,7 @@ config FEATURE_SH_NOFORK
config FEATURE_SH_HISTFILESIZE config FEATURE_SH_HISTFILESIZE
bool "Use $HISTFILESIZE" bool "Use $HISTFILESIZE"
default y default y
depends on HUSH || ASH depends on ASH || HUSH || SH_IS_ASH || BASH_IS_ASH || SH_IS_HUSH || BASH_IS_HUSH
help help
This option makes busybox shells to use $HISTFILESIZE variable This option makes busybox shells to use $HISTFILESIZE variable
to set shell history size. Note that its max value is capped to set shell history size. Note that its max value is capped

View File

@ -8,4 +8,4 @@ lib-y:=
INSERT INSERT
lib-$(CONFIG_SH_MATH_SUPPORT) += math.o lib-$(CONFIG_FEATURE_SH_MATH) += math.o

View File

@ -29,14 +29,14 @@
//config:config ASH_OPTIMIZE_FOR_SIZE //config:config ASH_OPTIMIZE_FOR_SIZE
//config: bool "Optimize for size instead of speed" //config: bool "Optimize for size instead of speed"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Compile ash for reduced size at the price of speed. //config: Compile ash for reduced size at the price of speed.
//config: //config:
//config:config ASH_INTERNAL_GLOB //config:config ASH_INTERNAL_GLOB
//config: bool "Use internal glob() implementation" //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: 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: help
//config: Do not use glob() function from libc, use internal implementation. //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: Use this if you are getting "glob.h: No such file or directory"
@ -45,7 +45,7 @@
//config:config ASH_RANDOM_SUPPORT //config:config ASH_RANDOM_SUPPORT
//config: bool "Pseudorandom generator and $RANDOM variable" //config: bool "Pseudorandom generator and $RANDOM variable"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable pseudorandom generator and dynamic variable "$RANDOM". //config: Enable pseudorandom generator and dynamic variable "$RANDOM".
//config: Each read of "$RANDOM" will generate a new pseudorandom value. //config: Each read of "$RANDOM" will generate a new pseudorandom value.
@ -56,7 +56,7 @@
//config:config ASH_EXPAND_PRMT //config:config ASH_EXPAND_PRMT
//config: bool "Expand prompt string" //config: bool "Expand prompt string"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: "PS#" may contain volatile content, such as backquote commands. //config: "PS#" may contain volatile content, such as backquote commands.
//config: This option recreates the prompt string from the environment //config: This option recreates the prompt string from the environment
@ -65,70 +65,70 @@
//config:config ASH_BASH_COMPAT //config:config ASH_BASH_COMPAT
//config: bool "bash-compatible extensions" //config: bool "bash-compatible extensions"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable bash-compatible extensions. //config: Enable bash-compatible extensions.
//config: //config:
//config:config ASH_IDLE_TIMEOUT //config:config ASH_IDLE_TIMEOUT
//config: bool "Idle timeout variable" //config: bool "Idle timeout variable"
//config: default n //config: default n
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enables bash-like auto-logout after $TMOUT seconds of idle time. //config: Enables bash-like auto-logout after $TMOUT seconds of idle time.
//config: //config:
//config:config ASH_JOB_CONTROL //config:config ASH_JOB_CONTROL
//config: bool "Job control" //config: bool "Job control"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable job control in the ash shell. //config: Enable job control in the ash shell.
//config: //config:
//config:config ASH_ALIAS //config:config ASH_ALIAS
//config: bool "Alias support" //config: bool "Alias support"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable alias support in the ash shell. //config: Enable alias support in the ash shell.
//config: //config:
//config:config ASH_GETOPTS //config:config ASH_GETOPTS
//config: bool "Builtin getopt to parse positional parameters" //config: bool "Builtin getopt to parse positional parameters"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable support for getopts builtin in ash. //config: Enable support for getopts builtin in ash.
//config: //config:
//config:config ASH_BUILTIN_ECHO //config:config ASH_BUILTIN_ECHO
//config: bool "Builtin version of 'echo'" //config: bool "Builtin version of 'echo'"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable support for echo builtin in ash. //config: Enable support for echo builtin in ash.
//config: //config:
//config:config ASH_BUILTIN_PRINTF //config:config ASH_BUILTIN_PRINTF
//config: bool "Builtin version of 'printf'" //config: bool "Builtin version of 'printf'"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable support for printf builtin in ash. //config: Enable support for printf builtin in ash.
//config: //config:
//config:config ASH_BUILTIN_TEST //config:config ASH_BUILTIN_TEST
//config: bool "Builtin version of 'test'" //config: bool "Builtin version of 'test'"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable support for test builtin in ash. //config: Enable support for test builtin in ash.
//config: //config:
//config:config ASH_HELP //config:config ASH_HELP
//config: bool "help builtin" //config: bool "help builtin"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable help builtin in ash. //config: Enable help builtin in ash.
//config: //config:
//config:config ASH_CMDCMD //config:config ASH_CMDCMD
//config: bool "'command' command to override shell builtins" //config: bool "'command' command to override shell builtins"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable support for the ash 'command' builtin, which allows //config: Enable support for the ash 'command' builtin, which allows
//config: you to run the specified command with the specified arguments, //config: you to run the specified command with the specified arguments,
@ -137,15 +137,17 @@
//config:config ASH_MAIL //config:config ASH_MAIL
//config: bool "Check for new mail on interactive shells" //config: bool "Check for new mail on interactive shells"
//config: default y //config: default y
//config: depends on ASH //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
//config: help //config: help
//config: Enable "check for new mail" function in the ash shell. //config: Enable "check for new mail" function in the ash shell.
//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) //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_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash))
//applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash)) //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_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 //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o
/* /*
@ -200,7 +202,7 @@
#include "unicode.h" #include "unicode.h"
#include "shell_common.h" #include "shell_common.h"
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
# include "math.h" # include "math.h"
#endif #endif
#if ENABLE_ASH_RANDOM_SUPPORT #if ENABLE_ASH_RANDOM_SUPPORT
@ -2144,6 +2146,7 @@ lookupvar(const char *name)
return NULL; return NULL;
} }
#if ENABLE_UNICODE_SUPPORT
static void static void
reinit_unicode_for_ash(void) reinit_unicode_for_ash(void)
{ {
@ -2160,6 +2163,9 @@ reinit_unicode_for_ash(void)
reinit_unicode(s); reinit_unicode(s);
} }
} }
#else
# define reinit_unicode_for_ash() ((void)0)
#endif
/* /*
* Search the environment of a builtin command. * 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 #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)) # define SIT_ITEM(a,b,c,d) (a | (b << 4) | (c << 8) | (d << 12))
#else #else
# define SIT_ITEM(a,b,c,d) (a | (b << 4) | (c << 8)) # 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)) \ if ((c) < 0 || (c) > (PEOF + ENABLE_ASH_ALIAS)) \
bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \ 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)); \ bb_error_msg_and_die("line:%d c:%d", __LINE__, (c)); \
((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf); \ ((S_I_T[syntax_index_table[c]] >> ((syntax)*4)) & 0xf); \
}) })
@ -4487,7 +4493,7 @@ cmdputs(const char *s)
case CTLBACKQ: case CTLBACKQ:
str = "$(...)"; str = "$(...)";
goto dostr; goto dostr;
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
case CTLARI: case CTLARI:
str = "$(("; str = "$((";
goto dostr; goto dostr;
@ -5547,7 +5553,7 @@ redirectsafe(union node *redir, int flags)
* We have to deal with backquotes, shell variables, and file metacharacters. * We have to deal with backquotes, shell variables, and file metacharacters.
*/ */
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
static arith_t static arith_t
ash_arith(const char *s) ash_arith(const char *s)
{ {
@ -5635,7 +5641,7 @@ static struct arglist exparg;
/* /*
* Our own itoa(). * 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) */ /* cvtnum() is used even if math support is off (to prepare $? values and such) */
typedef long arith_t; typedef long arith_t;
# define ARITH_FMT "%ld" # define ARITH_FMT "%ld"
@ -6148,7 +6154,7 @@ expbackq(union node *cmd, int flag)
stackblock() + startloc)); stackblock() + startloc));
} }
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
/* /*
* Expand arithmetic expression. Backup to start of expression, * Expand arithmetic expression. Backup to start of expression,
* evaluate, place result in (backed up) result, adjust string position. * 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, CTLESC,
CTLVAR, CTLVAR,
CTLBACKQ, CTLBACKQ,
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
CTLENDARI, CTLENDARI,
#endif #endif
'\0' '\0'
@ -6266,7 +6272,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
c = p[length]; c = p[length];
if (c) { if (c) {
if (!(c & 0x80) if (!(c & 0x80)
IF_SH_MATH_SUPPORT(|| c == CTLENDARI) IF_FEATURE_SH_MATH(|| c == CTLENDARI)
) { ) {
/* c == '=' || c == ':' || c == CTLENDARI */ /* c == '=' || c == ':' || c == CTLENDARI */
length++; length++;
@ -6346,7 +6352,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
expbackq(argbackq->n, flags | inquotes); expbackq(argbackq->n, flags | inquotes);
argbackq = argbackq->next; argbackq = argbackq->next;
goto start; goto start;
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
case CTLENDARI: case CTLENDARI:
p--; p--;
expari(flags | inquotes); expari(flags | inquotes);
@ -9265,7 +9271,7 @@ static int helpcmd(int, char **) FAST_FUNC;
#if MAX_HISTORY #if MAX_HISTORY
static int historycmd(int, char **) FAST_FUNC; static int historycmd(int, char **) FAST_FUNC;
#endif #endif
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
static int letcmd(int, char **) FAST_FUNC; static int letcmd(int, char **) FAST_FUNC;
#endif #endif
static int readcmd(int, char **) FAST_FUNC; static int readcmd(int, char **) FAST_FUNC;
@ -9345,7 +9351,7 @@ static const struct builtincmd builtintab[] = {
{ BUILTIN_REGULAR "jobs" , jobscmd }, { BUILTIN_REGULAR "jobs" , jobscmd },
{ BUILTIN_REGULAR "kill" , killcmd }, { BUILTIN_REGULAR "kill" , killcmd },
#endif #endif
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
{ BUILTIN_NOSPEC "let" , letcmd }, { BUILTIN_NOSPEC "let" , letcmd },
#endif #endif
{ BUILTIN_ASSIGN "local" , localcmd }, { BUILTIN_ASSIGN "local" , localcmd },
@ -11394,13 +11400,13 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
smallint quotef; smallint quotef;
smallint dblquote; smallint dblquote;
smallint oldstyle; 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 #if ENABLE_ASH_EXPAND_PRMT
smallint pssyntax; /* we are expanding a prompt string */ smallint pssyntax; /* we are expanding a prompt string */
#endif #endif
int varnest; /* levels of variables expansion */ int varnest; /* levels of variables expansion */
IF_SH_MATH_SUPPORT(int arinest;) /* levels of arithmetic expansion */ IF_FEATURE_SH_MATH(int arinest;) /* levels of arithmetic expansion */
IF_SH_MATH_SUPPORT(int parenlevel;) /* levels of parens in arithmetic */ IF_FEATURE_SH_MATH(int parenlevel;) /* levels of parens in arithmetic */
int dqvarnest; /* levels of variables expansion within double quotes */ int dqvarnest; /* levels of variables expansion within double quotes */
IF_ASH_BASH_COMPAT(smallint bash_dollar_squote = 0;) 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; startlinno = g_parsefile->linno;
bqlist = NULL; bqlist = NULL;
quotef = 0; quotef = 0;
IF_SH_MATH_SUPPORT(prevsyntax = 0;) IF_FEATURE_SH_MATH(prevsyntax = 0;)
#if ENABLE_ASH_EXPAND_PRMT #if ENABLE_ASH_EXPAND_PRMT
pssyntax = (syntax == PSSYNTAX); pssyntax = (syntax == PSSYNTAX);
if (pssyntax) if (pssyntax)
@ -11416,8 +11422,8 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
#endif #endif
dblquote = (syntax == DQSYNTAX); dblquote = (syntax == DQSYNTAX);
varnest = 0; varnest = 0;
IF_SH_MATH_SUPPORT(arinest = 0;) IF_FEATURE_SH_MATH(arinest = 0;)
IF_SH_MATH_SUPPORT(parenlevel = 0;) IF_FEATURE_SH_MATH(parenlevel = 0;)
dqvarnest = 0; dqvarnest = 0;
STARTSTACKSTR(out); STARTSTACKSTR(out);
@ -11524,7 +11530,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
} }
USTPUTC(c, out); USTPUTC(c, out);
break; break;
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
case CLP: /* '(' in arithmetic */ case CLP: /* '(' in arithmetic */
parenlevel++; parenlevel++;
USTPUTC(c, out); USTPUTC(c, out);
@ -11575,7 +11581,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
} /* for (;;) */ } /* for (;;) */
endword: endword:
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
if (syntax == ARISYNTAX) if (syntax == ARISYNTAX)
raise_error_syntax("missing '))'"); raise_error_syntax("missing '))'");
#endif #endif
@ -11754,7 +11760,7 @@ parsesub: {
} else if (c == '(') { } else if (c == '(') {
/* $(command) or $((arith)) */ /* $(command) or $((arith)) */
if (pgetc_eatbnl() == '(') { if (pgetc_eatbnl() == '(') {
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
PARSEARITH(); PARSEARITH();
#else #else
raise_error_syntax("you disabled math support for $((arith)) syntax"); raise_error_syntax("you disabled math support for $((arith)) syntax");
@ -12009,7 +12015,7 @@ parsebackq: {
goto parsebackq_newreturn; goto parsebackq_newreturn;
} }
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
/* /*
* Parse an arithmetic expansion (indicate start of one and set state) * 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; return 0;
} }
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
/* /*
* The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell. * The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell.
* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc. * Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
@ -13301,15 +13307,6 @@ init(void)
//usage:#define ash_full_usage "\n\n" //usage:#define ash_full_usage "\n\n"
//usage: "Unix shell interpreter" //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. * Process the shell command line arguments.
*/ */

View File

@ -99,7 +99,7 @@
//config:config HUSH_BASH_COMPAT //config:config HUSH_BASH_COMPAT
//config: bool "bash-compatible extensions" //config: bool "bash-compatible extensions"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable bash-compatible extensions. //config: Enable bash-compatible extensions.
//config: //config:
@ -113,14 +113,14 @@
//config:config HUSH_HELP //config:config HUSH_HELP
//config: bool "help builtin" //config: bool "help builtin"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable help builtin in hush. Code size + ~1 kbyte. //config: Enable help builtin in hush. Code size + ~1 kbyte.
//config: //config:
//config:config HUSH_INTERACTIVE //config:config HUSH_INTERACTIVE
//config: bool "Interactive mode" //config: bool "Interactive mode"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable interactive mode (prompt and command editing). //config: Enable interactive mode (prompt and command editing).
//config: Without this, hush simply reads and executes commands //config: Without this, hush simply reads and executes commands
@ -148,35 +148,35 @@
//config:config HUSH_TICK //config:config HUSH_TICK
//config: bool "Process substitution" //config: bool "Process substitution"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable process substitution `command` and $(command) in hush. //config: Enable process substitution `command` and $(command) in hush.
//config: //config:
//config:config HUSH_IF //config:config HUSH_IF
//config: bool "Support if/then/elif/else/fi" //config: bool "Support if/then/elif/else/fi"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable if/then/elif/else/fi in hush. //config: Enable if/then/elif/else/fi in hush.
//config: //config:
//config:config HUSH_LOOPS //config:config HUSH_LOOPS
//config: bool "Support for, while and until loops" //config: bool "Support for, while and until loops"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable for, while and until loops in hush. //config: Enable for, while and until loops in hush.
//config: //config:
//config:config HUSH_CASE //config:config HUSH_CASE
//config: bool "Support case ... esac statement" //config: bool "Support case ... esac statement"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable case ... esac statement in hush. +400 bytes. //config: Enable case ... esac statement in hush. +400 bytes.
//config: //config:
//config:config HUSH_FUNCTIONS //config:config HUSH_FUNCTIONS
//config: bool "Support funcname() { commands; } syntax" //config: bool "Support funcname() { commands; } syntax"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable support for shell functions in hush. +800 bytes. //config: Enable support for shell functions in hush. +800 bytes.
//config: //config:
@ -190,7 +190,7 @@
//config:config HUSH_RANDOM_SUPPORT //config:config HUSH_RANDOM_SUPPORT
//config: bool "Pseudorandom generator and $RANDOM variable" //config: bool "Pseudorandom generator and $RANDOM variable"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: Enable pseudorandom generator and dynamic variable "$RANDOM". //config: Enable pseudorandom generator and dynamic variable "$RANDOM".
//config: Each read of "$RANDOM" will generate a new pseudorandom value. //config: Each read of "$RANDOM" will generate a new pseudorandom value.
@ -198,14 +198,14 @@
//config:config HUSH_EXPORT_N //config:config HUSH_EXPORT_N
//config: bool "Support 'export -n' option" //config: bool "Support 'export -n' option"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: export -n unexports variables. It is a bash extension. //config: export -n unexports variables. It is a bash extension.
//config: //config:
//config:config HUSH_MODE_X //config:config HUSH_MODE_X
//config: bool "Support 'hush -x' option and 'set -x' command" //config: bool "Support 'hush -x' option and 'set -x' command"
//config: default y //config: default y
//config: depends on HUSH //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH
//config: help //config: help
//config: This instructs hush to print commands before execution. //config: This instructs hush to print commands before execution.
//config: Adds ~300 bytes. //config: Adds ~300 bytes.
@ -216,14 +216,15 @@
//config: select HUSH //config: select HUSH
//config: help //config: help
//config: msh is deprecated and will be removed, please migrate to hush. //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_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_MSH(APPLET(msh, BB_DIR_BIN, BB_SUID_DROP)) //applet:IF_MSH(APPLET_ODDNAME(msh, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
//applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, sh)) //applet:IF_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
//applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, bash)) //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_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 //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o
/* -i (interactive) and -s (read stdin) are also accepted, /* -i (interactive) and -s (read stdin) are also accepted,
@ -236,18 +237,6 @@
//usage:#define hush_full_usage "\n\n" //usage:#define hush_full_usage "\n\n"
//usage: "Unix shell interpreter" //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__) \ #if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
|| defined(__APPLE__) \ || 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 */ /* Subroutines for copying $(...) and `...` things */
static int add_till_backquote(o_string *dest, struct in_str *input, int in_dquote); 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; 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 */ /* Return code: 0 for OK, 1 for syntax error */
#if BB_MMU #if BB_MMU
@ -4333,13 +4322,13 @@ static int parse_dollar(o_string *as_string,
o_addchr(dest, SPECIAL_VAR_SYMBOL); o_addchr(dest, SPECIAL_VAR_SYMBOL);
break; break;
} }
#if ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_TICK #if ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_TICK
case '(': { case '(': {
unsigned pos; unsigned pos;
ch = i_getch(input); ch = i_getch(input);
nommu_addchr(as_string, ch); nommu_addchr(as_string, ch);
# if ENABLE_SH_MATH_SUPPORT # if ENABLE_FEATURE_SH_MATH
if (i_peek_and_eat_bkslash_nl(input) == '(') { if (i_peek_and_eat_bkslash_nl(input) == '(') {
ch = i_getch(input); ch = i_getch(input);
nommu_addchr(as_string, ch); 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; 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) static arith_t expand_and_evaluate_arith(const char *arg, const char **errmsg_p)
{ {
arith_state_t math_state; 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 #endif
else if (exp_op == ':') { 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. /* It's ${var:N[:M]} bashism.
* Note that in encoded form it has TWO parts: * Note that in encoded form it has TWO parts:
* var:N<SPECIAL_VAR_SYMBOL>M<SPECIAL_VAR_SYMBOL> * 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 #if ENABLE_HUSH_TICK
o_string subst_result = NULL_O_STRING; o_string subst_result = NULL_O_STRING;
#endif #endif
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
char arith_buf[sizeof(arith_t)*3 + 2]; char arith_buf[sizeof(arith_t)*3 + 2];
#endif #endif
@ -5698,7 +5687,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
val = subst_result.data; val = subst_result.data;
goto store_val; goto store_val;
#endif #endif
#if ENABLE_SH_MATH_SUPPORT #if ENABLE_FEATURE_SH_MATH
case '+': { /* <SPECIAL_VAR_SYMBOL>+cmd<SPECIAL_VAR_SYMBOL> */ case '+': { /* <SPECIAL_VAR_SYMBOL>+cmd<SPECIAL_VAR_SYMBOL> */
arith_t res; arith_t res;

View File

@ -63,7 +63,7 @@
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
#if ENABLE_SH_MATH_SUPPORT_64 #if ENABLE_FEATURE_SH_MATH_64
typedef long long arith_t; typedef long long arith_t;
#define ARITH_FMT "%lld" #define ARITH_FMT "%lld"
#define strto_arith_t strtoull #define strto_arith_t strtoull