diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/Config.in | 38 | ||||
-rw-r--r-- | shell/ash.c | 30 |
2 files changed, 49 insertions, 19 deletions
diff --git a/shell/Config.in b/shell/Config.in index dde8fd1..8f2f98e 100644 --- a/shell/Config.in +++ b/shell/Config.in @@ -95,12 +95,28 @@ config CONFIG_ASH_MATH_SUPPORT_64 large numbers. config CONFIG_ASH_GETOPTS - bool "Enable getopts builtin to parse positional parameters" + bool "Builtin getopt to parse positional parameters" default n depends on CONFIG_ASH help Enable getopts builtin in the ash shell. +config CONFIG_ASH_BUILTIN_ECHO + bool "Builtin version of 'echo'" + default y + select CONFIG_ECHO + depends on CONFIG_ASH + help + Enable support for echo, built in to ash. + +config CONFIG_ASH_BUILTIN_TEST + bool "Builtin version of 'test'" + default y + select CONFIG_TEST + depends on CONFIG_ASH + help + Enable support for test, built in to ash. + config CONFIG_ASH_CMDCMD bool "Enable cmdcmd to override shell builtins" default n @@ -110,21 +126,6 @@ config CONFIG_ASH_CMDCMD you to run the specified command with the specified arguments, even when there is an ash builtin command with the same name. -config CONFIG_ASH_BUILTIN_ECHO - bool "Enable builtin version of 'echo'" - default n - depends on CONFIG_ASH - help - Enable support for echo, built in to ash. - -# this entry also appears in coreutils/Config.in, next to the echo applet -config CONFIG_FEATURE_FANCY_ECHO - bool "Enable echo options (-n and -e)" - default y - depends on CONFIG_ASH_BUILTIN_ECHO - help - This adds options (-n and -e) to echo. - config CONFIG_ASH_MAIL bool "Check for new mail on interactive shells" default y @@ -229,6 +230,11 @@ config CONFIG_FEATURE_SH_STANDALONE_SHELL is generally used when creating a statically linked version of busybox for use as a rescue shell, in the event that you screw up your system. + Note that this will *also* cause applets to take precedence + over shell builtins of the same name. So turning this on will + eliminate any performance gained by turning on the builtin "echo" + and "test" commands in ash. + Note that when using this option, the shell will attempt to directly run '/bin/busybox'. If you do not have the busybox binary sitting in that exact location with that exact name, this option will not work at diff --git a/shell/ash.c b/shell/ash.c index 962813d..713898a 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -1225,6 +1225,9 @@ static int evalcmd(int, char **); #ifdef CONFIG_ASH_BUILTIN_ECHO static int echocmd(int, char **); #endif +#ifdef CONFIG_ASH_BUILTIN_TEST +static int testcmd(int, char **); +#endif static int execcmd(int, char **); static int exitcmd(int, char **); static int exportcmd(int, char **); @@ -1286,10 +1289,15 @@ struct builtincmd { #define COMMANDCMD (builtincmd + 5 + \ - ENABLE_ASH_ALIAS + ENABLE_ASH_JOB_CONTROL) + 2 * ENABLE_ASH_BUILTIN_TEST + \ + ENABLE_ASH_ALIAS + \ + ENABLE_ASH_JOB_CONTROL) #define EXECCMD (builtincmd + 7 + \ - ENABLE_ASH_CMDCMD + ENABLE_ASH_ALIAS + \ - ENABLE_ASH_BUILTIN_ECHO + ENABLE_ASH_JOB_CONTROL) + 2 * ENABLE_ASH_BUILTIN_TEST + \ + ENABLE_ASH_ALIAS + \ + ENABLE_ASH_JOB_CONTROL + \ + ENABLE_ASH_CMDCMD + \ + ENABLE_ASH_BUILTIN_ECHO) #define BUILTIN_NOSPEC "0" #define BUILTIN_SPECIAL "1" @@ -1307,6 +1315,10 @@ struct builtincmd { static const struct builtincmd builtincmd[] = { { BUILTIN_SPEC_REG ".", dotcmd }, { BUILTIN_SPEC_REG ":", truecmd }, +#ifdef CONFIG_ASH_BUILTIN_TEST + { BUILTIN_REGULAR "[", testcmd }, + { BUILTIN_REGULAR "[[", testcmd }, +#endif #ifdef CONFIG_ASH_ALIAS { BUILTIN_REG_ASSG "alias", aliascmd }, #endif @@ -1353,6 +1365,9 @@ static const struct builtincmd builtincmd[] = { { BUILTIN_SPEC_REG "set", setcmd }, { BUILTIN_SPEC_REG "source", dotcmd }, { BUILTIN_SPEC_REG "shift", shiftcmd }, +#ifdef CONFIG_ASH_BUILTIN_TEST + { BUILTIN_REGULAR "test", testcmd }, +#endif { BUILTIN_SPEC_REG "times", timescmd }, { BUILTIN_SPEC_REG "trap", trapcmd }, { BUILTIN_REGULAR "true", truecmd }, @@ -8143,6 +8158,15 @@ echocmd(int argc, char **argv) return bb_echo(argc, argv); } #endif + +#ifdef CONFIG_ASH_BUILTIN_TEST +static int +testcmd(int argc, char **argv) +{ + return bb_test(argc, argv); +} +#endif + /* memalloc.c */ /* |