diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-11-23 18:31:48 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-11-23 18:31:48 +0100 |
commit | 15fb91cefb22d64952f34fe246fc8f257172af63 (patch) | |
tree | b26c3168f2ea5e185eee1041c6f521855398783a | |
parent | 73f743a381dc389287d2d0e56a2b7988f67c0bfc (diff) | |
download | busybox-w32-15fb91cefb22d64952f34fe246fc8f257172af63.tar.gz busybox-w32-15fb91cefb22d64952f34fe246fc8f257172af63.tar.bz2 busybox-w32-15fb91cefb22d64952f34fe246fc8f257172af63.zip |
test: make [ and [[ forms individually selectable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/test.c | 26 | ||||
-rwxr-xr-x | include/applets.h.sh | 8 | ||||
-rw-r--r-- | shell/ash.c | 4 |
3 files changed, 29 insertions, 9 deletions
diff --git a/coreutils/test.c b/coreutils/test.c index 81c9b7dfe..9e18ee986 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -27,19 +27,33 @@ | |||
27 | //config: returning an appropriate exit code. The bash shell | 27 | //config: returning an appropriate exit code. The bash shell |
28 | //config: has test built in, ash can build it in optionally. | 28 | //config: has test built in, ash can build it in optionally. |
29 | //config: | 29 | //config: |
30 | //config:config TEST1 | ||
31 | //config: bool "test as [" | ||
32 | //config: default y | ||
33 | //config: help | ||
34 | //config: Provide test command in the "[ EXPR ]" form | ||
35 | //config: | ||
36 | //config:config TEST2 | ||
37 | //config: bool "test as [[" | ||
38 | //config: default y | ||
39 | //config: help | ||
40 | //config: Provide test command in the "[[ EXPR ]]" form | ||
41 | //config: | ||
30 | //config:config FEATURE_TEST_64 | 42 | //config:config FEATURE_TEST_64 |
31 | //config: bool "Extend test to 64 bit" | 43 | //config: bool "Extend test to 64 bit" |
32 | //config: default y | 44 | //config: default y |
33 | //config: depends on TEST || ASH_BUILTIN_TEST || HUSH | 45 | //config: depends on TEST || TEST1 || TEST2 || ASH_BUILTIN_TEST || HUSH |
34 | //config: help | 46 | //config: help |
35 | //config: Enable 64-bit support in test. | 47 | //config: Enable 64-bit support in test. |
36 | 48 | ||
37 | //applet:IF_TEST(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) | ||
38 | //applet:IF_TEST(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) | ||
39 | //applet:IF_TEST(APPLET_NOFORK(test, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) | 49 | //applet:IF_TEST(APPLET_NOFORK(test, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) |
50 | //applet:IF_TEST1(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) | ||
51 | //applet:IF_TEST2(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) | ||
40 | 52 | ||
41 | //kbuild:lib-$(CONFIG_TEST) += test.o test_ptr_hack.o | 53 | //kbuild:lib-$(CONFIG_TEST) += test.o test_ptr_hack.o |
42 | //kbuild:lib-$(CONFIG_ASH) += test.o test_ptr_hack.o | 54 | //kbuild:lib-$(CONFIG_TEST1) += test.o test_ptr_hack.o |
55 | //kbuild:lib-$(CONFIG_TEST2) += test.o test_ptr_hack.o | ||
56 | //kbuild:lib-$(CONFIG_ASH_BUILTIN_TEST) += test.o test_ptr_hack.o | ||
43 | //kbuild:lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o | 57 | //kbuild:lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o |
44 | 58 | ||
45 | /* "test --help" is special-cased to ignore --help */ | 59 | /* "test --help" is special-cased to ignore --help */ |
@@ -827,7 +841,9 @@ int test_main(int argc, char **argv) | |||
827 | const char *arg0; | 841 | const char *arg0; |
828 | 842 | ||
829 | arg0 = bb_basename(argv[0]); | 843 | arg0 = bb_basename(argv[0]); |
830 | if (arg0[0] == '[') { | 844 | if ((ENABLE_TEST1 || ENABLE_TEST2 || ENABLE_ASH_BUILTIN_TEST || ENABLE_HUSH) |
845 | && (arg0[0] == '[') | ||
846 | ) { | ||
831 | --argc; | 847 | --argc; |
832 | if (!arg0[1]) { /* "[" ? */ | 848 | if (!arg0[1]) { /* "[" ? */ |
833 | if (NOT_LONE_CHAR(argv[argc], ']')) { | 849 | if (NOT_LONE_CHAR(argv[argc], ']')) { |
diff --git a/include/applets.h.sh b/include/applets.h.sh index 6b8046c4b..bab4e0d72 100755 --- a/include/applets.h.sh +++ b/include/applets.h.sh | |||
@@ -5,13 +5,17 @@ | |||
5 | 5 | ||
6 | # CONFIG_applet names | 6 | # CONFIG_applet names |
7 | grep ^IF_ applets.h | grep -v IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ | 7 | grep ^IF_ applets.h | grep -v IF_FEATURE_ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ |
8 | | grep -v MODPROBE_SMALL | sed 's/BB_SYSCTL/SYSCTL/' \ | 8 | | grep -v MODPROBE_SMALL \ |
9 | | sed 's/BB_SYSCTL/SYSCTL/' \ | ||
10 | | sed 's/TEST1/[/' \ | ||
11 | | sed 's/TEST2/[[/' \ | ||
9 | | sort | uniq \ | 12 | | sort | uniq \ |
10 | >applets_APP1 | 13 | >applets_APP1 |
11 | 14 | ||
12 | # command line applet names | 15 | # command line applet names |
13 | grep ^IF_ applets.h | sed -e's/ //g' -e's/.*(\([a-z[][^,]*\),.*/\1/' \ | 16 | grep ^IF_ applets.h | sed -e's/ //g' -e's/.*(\([a-z[][^,]*\),.*/\1/' \ |
14 | | grep -v '^bash$' | grep -v '^sh$' \ | 17 | | grep -v '^bash$' \ |
18 | | grep -v '^sh$' \ | ||
15 | | tr a-z A-Z \ | 19 | | tr a-z A-Z \ |
16 | | sort | uniq \ | 20 | | sort | uniq \ |
17 | >applets_APP2 | 21 | >applets_APP2 |
diff --git a/shell/ash.c b/shell/ash.c index 87f2127a1..15246f55f 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -9282,9 +9282,9 @@ static const struct builtincmd builtintab[] = { | |||
9282 | { BUILTIN_SPEC_REG ":" , truecmd }, | 9282 | { BUILTIN_SPEC_REG ":" , truecmd }, |
9283 | #if ENABLE_ASH_BUILTIN_TEST | 9283 | #if ENABLE_ASH_BUILTIN_TEST |
9284 | { BUILTIN_REGULAR "[" , testcmd }, | 9284 | { BUILTIN_REGULAR "[" , testcmd }, |
9285 | #if ENABLE_ASH_BASH_COMPAT | 9285 | # if ENABLE_ASH_BASH_COMPAT |
9286 | { BUILTIN_REGULAR "[[" , testcmd }, | 9286 | { BUILTIN_REGULAR "[[" , testcmd }, |
9287 | #endif | 9287 | # endif |
9288 | #endif | 9288 | #endif |
9289 | #if ENABLE_ASH_ALIAS | 9289 | #if ENABLE_ASH_ALIAS |
9290 | { BUILTIN_REG_ASSG "alias" , aliascmd }, | 9290 | { BUILTIN_REG_ASSG "alias" , aliascmd }, |