diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-10 15:13:30 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-10 15:13:30 +0100 |
commit | 265062d59dd46065ad34519f04615fb2cecefe8a (patch) | |
tree | 6f5d8a3f87a9718b06dca325554410a3337f5b0f | |
parent | f560422fa079b07a761a572ca4f9cf287c2cc47e (diff) | |
download | busybox-265062d59dd46065ad34519f04615fb2cecefe8a.tar.gz |
shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo
This makes hash and ash more symmetrical wrt config menu and config
options.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | configs/TEST_nommu_defconfig | 6 | ||||
-rw-r--r-- | configs/TEST_noprintf_defconfig | 6 | ||||
-rw-r--r-- | configs/TEST_rh9_defconfig | 6 | ||||
-rw-r--r-- | configs/android2_defconfig | 6 | ||||
-rw-r--r-- | configs/android_502_defconfig | 6 | ||||
-rw-r--r-- | configs/android_defconfig | 6 | ||||
-rw-r--r-- | configs/android_ndk_defconfig | 6 | ||||
-rw-r--r-- | configs/cygwin_defconfig | 6 | ||||
-rw-r--r-- | configs/freebsd_defconfig | 6 | ||||
-rw-r--r-- | coreutils/Kbuild.src | 6 | ||||
-rw-r--r-- | coreutils/echo.c | 5 | ||||
-rw-r--r-- | coreutils/printf.c | 5 | ||||
-rw-r--r-- | coreutils/test.c | 17 | ||||
-rw-r--r-- | shell/ash.c | 26 | ||||
-rw-r--r-- | shell/hush.c | 16 | ||||
-rwxr-xr-x | testsuite/mdev.tests | 2 |
16 files changed, 72 insertions, 59 deletions
diff --git a/configs/TEST_nommu_defconfig b/configs/TEST_nommu_defconfig index 08351a294..d9ec41cd0 100644 --- a/configs/TEST_nommu_defconfig +++ b/configs/TEST_nommu_defconfig @@ -879,9 +879,9 @@ CONFIG_FEATURE_SH_IS_HUSH=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/configs/TEST_noprintf_defconfig b/configs/TEST_noprintf_defconfig index 70dacece0..c7330ed5d 100644 --- a/configs/TEST_noprintf_defconfig +++ b/configs/TEST_noprintf_defconfig @@ -873,9 +873,9 @@ CONFIG_SV_DEFAULT_SERVICE_DIR="" # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/configs/TEST_rh9_defconfig b/configs/TEST_rh9_defconfig index 4a5fad324..86e13cd53 100644 --- a/configs/TEST_rh9_defconfig +++ b/configs/TEST_rh9_defconfig @@ -893,9 +893,9 @@ CONFIG_ASH_BASH_COMPAT=y CONFIG_ASH_JOB_CONTROL=y CONFIG_ASH_ALIAS=y CONFIG_ASH_GETOPTS=y -CONFIG_ASH_BUILTIN_ECHO=y -CONFIG_ASH_BUILTIN_PRINTF=y -CONFIG_ASH_BUILTIN_TEST=y +CONFIG_ASH_ECHO=y +CONFIG_ASH_PRINTF=y +CONFIG_ASH_TEST=y CONFIG_ASH_CMDCMD=y # CONFIG_ASH_MAIL is not set CONFIG_ASH_OPTIMIZE_FOR_SIZE=y diff --git a/configs/android2_defconfig b/configs/android2_defconfig index 754f612c6..9338f66ac 100644 --- a/configs/android2_defconfig +++ b/configs/android2_defconfig @@ -936,9 +936,9 @@ CONFIG_SOFTLIMIT=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/configs/android_502_defconfig b/configs/android_502_defconfig index 8ea6c295d..316063440 100644 --- a/configs/android_502_defconfig +++ b/configs/android_502_defconfig @@ -1081,9 +1081,9 @@ CONFIG_ASH_BASH_COMPAT=y CONFIG_ASH_JOB_CONTROL=y CONFIG_ASH_ALIAS=y CONFIG_ASH_GETOPTS=y -CONFIG_ASH_BUILTIN_ECHO=y -CONFIG_ASH_BUILTIN_PRINTF=y -CONFIG_ASH_BUILTIN_TEST=y +CONFIG_ASH_ECHO=y +CONFIG_ASH_PRINTF=y +CONFIG_ASH_TEST=y CONFIG_ASH_HELP=y CONFIG_ASH_CMDCMD=y # CONFIG_ASH_MAIL is not set diff --git a/configs/android_defconfig b/configs/android_defconfig index 30e888ac7..cd3490c4e 100644 --- a/configs/android_defconfig +++ b/configs/android_defconfig @@ -968,9 +968,9 @@ CONFIG_SOFTLIMIT=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/configs/android_ndk_defconfig b/configs/android_ndk_defconfig index 716ec9a5d..f2773be46 100644 --- a/configs/android_ndk_defconfig +++ b/configs/android_ndk_defconfig @@ -996,9 +996,9 @@ CONFIG_SOFTLIMIT=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_HELP is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set diff --git a/configs/cygwin_defconfig b/configs/cygwin_defconfig index b856482f6..816f76e65 100644 --- a/configs/cygwin_defconfig +++ b/configs/cygwin_defconfig @@ -936,9 +936,9 @@ CONFIG_ASH_BASH_COMPAT=y CONFIG_ASH_JOB_CONTROL=y CONFIG_ASH_ALIAS=y CONFIG_ASH_GETOPTS=y -CONFIG_ASH_BUILTIN_ECHO=y -CONFIG_ASH_BUILTIN_PRINTF=y -CONFIG_ASH_BUILTIN_TEST=y +CONFIG_ASH_ECHO=y +CONFIG_ASH_PRINTF=y +CONFIG_ASH_TEST=y CONFIG_ASH_CMDCMD=y # CONFIG_ASH_MAIL is not set CONFIG_ASH_OPTIMIZE_FOR_SIZE=y diff --git a/configs/freebsd_defconfig b/configs/freebsd_defconfig index 4f14d3be9..d223b7230 100644 --- a/configs/freebsd_defconfig +++ b/configs/freebsd_defconfig @@ -912,9 +912,9 @@ CONFIG_ASH=y # CONFIG_ASH_JOB_CONTROL is not set # CONFIG_ASH_ALIAS is not set # CONFIG_ASH_GETOPTS is not set -# CONFIG_ASH_BUILTIN_ECHO is not set -# CONFIG_ASH_BUILTIN_PRINTF is not set -# CONFIG_ASH_BUILTIN_TEST is not set +# CONFIG_ASH_ECHO is not set +# CONFIG_ASH_PRINTF is not set +# CONFIG_ASH_TEST is not set # CONFIG_ASH_CMDCMD is not set # CONFIG_ASH_MAIL is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src index d0b3f629b..a805b64fe 100644 --- a/coreutils/Kbuild.src +++ b/coreutils/Kbuild.src @@ -16,9 +16,3 @@ lib-$(CONFIG_CRONTAB) += cat.o # crontab -l lib-$(CONFIG_ADDUSER) += chown.o # used by adduser lib-$(CONFIG_ADDGROUP) += chown.o # used by addgroup lib-$(CONFIG_FTPD) += ls.o # used by ftpd - -lib-$(CONFIG_ASH_BUILTIN_ECHO) += echo.o -lib-$(CONFIG_HUSH_ECHO) += echo.o - -lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o -lib-$(CONFIG_HUSH_PRINTF) += printf.o diff --git a/coreutils/echo.c b/coreutils/echo.c index d0dba650d..a7e4ca9ac 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c @@ -28,12 +28,15 @@ //config:config FEATURE_FANCY_ECHO //config: bool "Enable -n and -e options" //config: default y -//config: depends on ECHO || ASH_BUILTIN_ECHO || HUSH_ECHO +//config: depends on ECHO || ASH_ECHO || HUSH_ECHO //applet:IF_ECHO(APPLET_NOFORK(echo, echo, BB_DIR_BIN, BB_SUID_DROP, echo)) //kbuild:lib-$(CONFIG_ECHO) += echo.o +//kbuild:lib-$(CONFIG_ASH_ECHO) += echo.o +//kbuild:lib-$(CONFIG_HUSH_ECHO) += echo.o + /* BB_AUDIT SUSv3 compliant -- unless configured as fancy echo. */ /* http://www.opengroup.org/onlinepubs/007904975/utilities/echo.html */ diff --git a/coreutils/printf.c b/coreutils/printf.c index 6c8e115d8..bc22e0ee7 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c @@ -49,6 +49,9 @@ //kbuild:lib-$(CONFIG_PRINTF) += printf.o +//kbuild:lib-$(CONFIG_ASH_PRINTF) += printf.o +//kbuild:lib-$(CONFIG_HUSH_PRINTF) += printf.o + //usage:#define printf_trivial_usage //usage: "FORMAT [ARG]..." //usage:#define printf_full_usage "\n\n" @@ -417,7 +420,7 @@ int printf_main(int argc UNUSED_PARAM, char **argv) if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2]) argv++; if (!argv[1]) { - if (ENABLE_ASH_BUILTIN_PRINTF + if (ENABLE_ASH_PRINTF && applet_name[0] != 'p' ) { bb_error_msg("usage: printf FORMAT [ARGUMENT...]"); diff --git a/coreutils/test.c b/coreutils/test.c index 288f66508..edc625f57 100644 --- a/coreutils/test.c +++ b/coreutils/test.c @@ -42,21 +42,20 @@ //config:config FEATURE_TEST_64 //config: bool "Extend test to 64 bit" //config: default y -//config: depends on TEST || TEST1 || TEST2 || ASH_BUILTIN_TEST || HUSH +//config: depends on TEST || TEST1 || TEST2 || ASH_TEST || HUSH_TEST //config: help //config: Enable 64-bit support in test. //applet:IF_TEST(APPLET_NOFORK(test, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) -//applet:IF_TEST1(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) -//applet:IF_TEST2(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) +//applet:IF_TEST1(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) +//applet:IF_TEST2(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) -//kbuild:lib-$(CONFIG_TEST) += test.o test_ptr_hack.o +//kbuild:lib-$(CONFIG_TEST) += test.o test_ptr_hack.o //kbuild:lib-$(CONFIG_TEST1) += 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_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 + +//kbuild:lib-$(CONFIG_ASH_TEST) += test.o test_ptr_hack.o +//kbuild:lib-$(CONFIG_HUSH_TEST) += test.o test_ptr_hack.o /* "test --help" is special-cased to ignore --help */ //usage:#define test_trivial_usage NOUSAGE_STR @@ -843,7 +842,7 @@ int test_main(int argc, char **argv) const char *arg0; arg0 = bb_basename(argv[0]); - if ((ENABLE_TEST1 || ENABLE_TEST2 || ENABLE_ASH_BUILTIN_TEST || ENABLE_HUSH) + if ((ENABLE_TEST1 || ENABLE_TEST2 || ENABLE_ASH_TEST || ENABLE_HUSH_TEST) && (arg0[0] == '[') ) { --argc; diff --git a/shell/ash.c b/shell/ash.c index 20ed9652c..7c1204a47 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -99,17 +99,17 @@ //config: are checked for mtime changes, and "you have mail" //config: message is printed if change is detected. //config: -//config:config ASH_BUILTIN_ECHO +//config:config ASH_ECHO //config: bool "echo builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: -//config:config ASH_BUILTIN_PRINTF +//config:config ASH_PRINTF //config: bool "printf builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH //config: -//config:config ASH_BUILTIN_TEST +//config:config ASH_TEST //config: bool "test builtin" //config: default y //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH @@ -9292,13 +9292,13 @@ static int ulimitcmd(int, char **) FAST_FUNC; #define BUILTIN_SPEC_REG_ASSG "7" /* Stubs for calling non-FAST_FUNC's */ -#if ENABLE_ASH_BUILTIN_ECHO +#if ENABLE_ASH_ECHO static int FAST_FUNC echocmd(int argc, char **argv) { return echo_main(argc, argv); } #endif -#if ENABLE_ASH_BUILTIN_PRINTF +#if ENABLE_ASH_PRINTF static int FAST_FUNC printfcmd(int argc, char **argv) { return printf_main(argc, argv); } #endif -#if ENABLE_ASH_BUILTIN_TEST +#if ENABLE_ASH_TEST static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); } #endif @@ -9306,7 +9306,7 @@ static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, a static const struct builtincmd builtintab[] = { { BUILTIN_SPEC_REG "." , dotcmd }, { BUILTIN_SPEC_REG ":" , truecmd }, -#if ENABLE_ASH_BUILTIN_TEST +#if ENABLE_ASH_TEST { BUILTIN_REGULAR "[" , testcmd }, # if ENABLE_ASH_BASH_COMPAT { BUILTIN_REGULAR "[[" , testcmd }, @@ -9325,7 +9325,7 @@ static const struct builtincmd builtintab[] = { { BUILTIN_REGULAR "command" , commandcmd }, #endif { BUILTIN_SPEC_REG "continue", breakcmd }, -#if ENABLE_ASH_BUILTIN_ECHO +#if ENABLE_ASH_ECHO { BUILTIN_REGULAR "echo" , echocmd }, #endif { BUILTIN_SPEC_REG "eval" , NULL }, /*evalcmd() has a differing prototype*/ @@ -9354,7 +9354,7 @@ static const struct builtincmd builtintab[] = { { BUILTIN_NOSPEC "let" , letcmd }, #endif { BUILTIN_ASSIGN "local" , localcmd }, -#if ENABLE_ASH_BUILTIN_PRINTF +#if ENABLE_ASH_PRINTF { BUILTIN_REGULAR "printf" , printfcmd }, #endif { BUILTIN_NOSPEC "pwd" , pwdcmd }, @@ -9366,7 +9366,7 @@ static const struct builtincmd builtintab[] = { #if ENABLE_ASH_BASH_COMPAT { BUILTIN_SPEC_REG "source" , dotcmd }, #endif -#if ENABLE_ASH_BUILTIN_TEST +#if ENABLE_ASH_TEST { BUILTIN_REGULAR "test" , testcmd }, #endif { BUILTIN_SPEC_REG "times" , timescmd }, @@ -9385,15 +9385,15 @@ static const struct builtincmd builtintab[] = { /* Should match the above table! */ #define COMMANDCMD (builtintab + \ /* . : */ 2 + \ - /* [ */ 1 * ENABLE_ASH_BUILTIN_TEST + \ - /* [[ */ 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \ + /* [ */ 1 * ENABLE_ASH_TEST + \ + /* [[ */ 1 * ENABLE_ASH_TEST * ENABLE_ASH_BASH_COMPAT + \ /* alias */ 1 * ENABLE_ASH_ALIAS + \ /* bg */ 1 * ENABLE_ASH_JOB_CONTROL + \ /* break cd cddir */ 3) #define EVALCMD (COMMANDCMD + \ /* command */ 1 * ENABLE_ASH_CMDCMD + \ /* continue */ 1 + \ - /* echo */ 1 * ENABLE_ASH_BUILTIN_ECHO + \ + /* echo */ 1 * ENABLE_ASH_ECHO + \ 0) #define EXECCMD (EVALCMD + \ /* eval */ 1) diff --git a/shell/hush.c b/shell/hush.c index 9e508fc6d..c0325cf5e 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -197,6 +197,11 @@ //config: default y //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH //config: +//config:config HUSH_TEST +//config: bool "test builtin" +//config: default y +//config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH +//config: //config:config HUSH_HELP //config: bool "help builtin" //config: default y @@ -942,7 +947,9 @@ static int builtin_set(char **argv) FAST_FUNC; #endif static int builtin_shift(char **argv) FAST_FUNC; static int builtin_source(char **argv) FAST_FUNC; +#if ENABLE_HUSH_TEST static int builtin_test(char **argv) FAST_FUNC; +#endif #if ENABLE_HUSH_TRAP static int builtin_trap(char **argv) FAST_FUNC; #endif @@ -1061,7 +1068,9 @@ static const struct built_in_command bltins1[] = { #endif }; static const struct built_in_command bltins2[] = { +#if ENABLE_HUSH_TEST BLTIN("[" , builtin_test , NULL), +#endif #if ENABLE_HUSH_ECHO BLTIN("echo" , builtin_echo , NULL), #endif @@ -1069,7 +1078,9 @@ static const struct built_in_command bltins2[] = { BLTIN("printf" , builtin_printf , NULL), #endif BLTIN("pwd" , builtin_pwd , NULL), +#if ENABLE_HUSH_TEST BLTIN("test" , builtin_test , NULL), +#endif }; @@ -8791,6 +8802,7 @@ static int FAST_FUNC builtin_true(char **argv UNUSED_PARAM) return 0; } +#if ENABLE_HUSH_TEST || ENABLE_HUSH_ECHO || ENABLE_HUSH_PRINTF || ENABLE_HUSH_KILL static int run_applet_main(char **argv, int (*applet_main_func)(int argc, char **argv)) { int argc = 0; @@ -8800,11 +8812,13 @@ static int run_applet_main(char **argv, int (*applet_main_func)(int argc, char * } return applet_main_func(argc, argv - argc); } - +#endif +#if ENABLE_HUSH_TEST static int FAST_FUNC builtin_test(char **argv) { return run_applet_main(argv, test_main); } +#endif #if ENABLE_HUSH_ECHO static int FAST_FUNC builtin_echo(char **argv) { diff --git a/testsuite/mdev.tests b/testsuite/mdev.tests index 59873011a..8515aff31 100755 --- a/testsuite/mdev.tests +++ b/testsuite/mdev.tests @@ -168,7 +168,7 @@ SKIP= # continuing to use directory structure from prev test rm -rf mdev.testdir/dev/* echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf -optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_SH_IS_ASH ASH_BUILTIN_ECHO +optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_SH_IS_ASH ASH_ECHO testing "mdev command" \ "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; ls -lnR mdev.testdir/dev | $FILTER_LS" \ |