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 /shell | |
parent | f560422fa079b07a761a572ca4f9cf287c2cc47e (diff) | |
download | busybox-w32-265062d59dd46065ad34519f04615fb2cecefe8a.tar.gz busybox-w32-265062d59dd46065ad34519f04615fb2cecefe8a.tar.bz2 busybox-w32-265062d59dd46065ad34519f04615fb2cecefe8a.zip |
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>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 26 | ||||
-rw-r--r-- | shell/hush.c | 16 |
2 files changed, 28 insertions, 14 deletions
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 @@ | |||
99 | //config: are checked for mtime changes, and "you have mail" | 99 | //config: are checked for mtime changes, and "you have mail" |
100 | //config: message is printed if change is detected. | 100 | //config: message is printed if change is detected. |
101 | //config: | 101 | //config: |
102 | //config:config ASH_BUILTIN_ECHO | 102 | //config:config ASH_ECHO |
103 | //config: bool "echo builtin" | 103 | //config: bool "echo builtin" |
104 | //config: default y | 104 | //config: default y |
105 | //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH | 105 | //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH |
106 | //config: | 106 | //config: |
107 | //config:config ASH_BUILTIN_PRINTF | 107 | //config:config ASH_PRINTF |
108 | //config: bool "printf builtin" | 108 | //config: bool "printf builtin" |
109 | //config: default y | 109 | //config: default y |
110 | //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH | 110 | //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH |
111 | //config: | 111 | //config: |
112 | //config:config ASH_BUILTIN_TEST | 112 | //config:config ASH_TEST |
113 | //config: bool "test builtin" | 113 | //config: bool "test builtin" |
114 | //config: default y | 114 | //config: default y |
115 | //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH | 115 | //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH |
@@ -9292,13 +9292,13 @@ static int ulimitcmd(int, char **) FAST_FUNC; | |||
9292 | #define BUILTIN_SPEC_REG_ASSG "7" | 9292 | #define BUILTIN_SPEC_REG_ASSG "7" |
9293 | 9293 | ||
9294 | /* Stubs for calling non-FAST_FUNC's */ | 9294 | /* Stubs for calling non-FAST_FUNC's */ |
9295 | #if ENABLE_ASH_BUILTIN_ECHO | 9295 | #if ENABLE_ASH_ECHO |
9296 | static int FAST_FUNC echocmd(int argc, char **argv) { return echo_main(argc, argv); } | 9296 | static int FAST_FUNC echocmd(int argc, char **argv) { return echo_main(argc, argv); } |
9297 | #endif | 9297 | #endif |
9298 | #if ENABLE_ASH_BUILTIN_PRINTF | 9298 | #if ENABLE_ASH_PRINTF |
9299 | static int FAST_FUNC printfcmd(int argc, char **argv) { return printf_main(argc, argv); } | 9299 | static int FAST_FUNC printfcmd(int argc, char **argv) { return printf_main(argc, argv); } |
9300 | #endif | 9300 | #endif |
9301 | #if ENABLE_ASH_BUILTIN_TEST | 9301 | #if ENABLE_ASH_TEST |
9302 | static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); } | 9302 | static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); } |
9303 | #endif | 9303 | #endif |
9304 | 9304 | ||
@@ -9306,7 +9306,7 @@ static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, a | |||
9306 | static const struct builtincmd builtintab[] = { | 9306 | static const struct builtincmd builtintab[] = { |
9307 | { BUILTIN_SPEC_REG "." , dotcmd }, | 9307 | { BUILTIN_SPEC_REG "." , dotcmd }, |
9308 | { BUILTIN_SPEC_REG ":" , truecmd }, | 9308 | { BUILTIN_SPEC_REG ":" , truecmd }, |
9309 | #if ENABLE_ASH_BUILTIN_TEST | 9309 | #if ENABLE_ASH_TEST |
9310 | { BUILTIN_REGULAR "[" , testcmd }, | 9310 | { BUILTIN_REGULAR "[" , testcmd }, |
9311 | # if ENABLE_ASH_BASH_COMPAT | 9311 | # if ENABLE_ASH_BASH_COMPAT |
9312 | { BUILTIN_REGULAR "[[" , testcmd }, | 9312 | { BUILTIN_REGULAR "[[" , testcmd }, |
@@ -9325,7 +9325,7 @@ static const struct builtincmd builtintab[] = { | |||
9325 | { BUILTIN_REGULAR "command" , commandcmd }, | 9325 | { BUILTIN_REGULAR "command" , commandcmd }, |
9326 | #endif | 9326 | #endif |
9327 | { BUILTIN_SPEC_REG "continue", breakcmd }, | 9327 | { BUILTIN_SPEC_REG "continue", breakcmd }, |
9328 | #if ENABLE_ASH_BUILTIN_ECHO | 9328 | #if ENABLE_ASH_ECHO |
9329 | { BUILTIN_REGULAR "echo" , echocmd }, | 9329 | { BUILTIN_REGULAR "echo" , echocmd }, |
9330 | #endif | 9330 | #endif |
9331 | { BUILTIN_SPEC_REG "eval" , NULL }, /*evalcmd() has a differing prototype*/ | 9331 | { BUILTIN_SPEC_REG "eval" , NULL }, /*evalcmd() has a differing prototype*/ |
@@ -9354,7 +9354,7 @@ static const struct builtincmd builtintab[] = { | |||
9354 | { BUILTIN_NOSPEC "let" , letcmd }, | 9354 | { BUILTIN_NOSPEC "let" , letcmd }, |
9355 | #endif | 9355 | #endif |
9356 | { BUILTIN_ASSIGN "local" , localcmd }, | 9356 | { BUILTIN_ASSIGN "local" , localcmd }, |
9357 | #if ENABLE_ASH_BUILTIN_PRINTF | 9357 | #if ENABLE_ASH_PRINTF |
9358 | { BUILTIN_REGULAR "printf" , printfcmd }, | 9358 | { BUILTIN_REGULAR "printf" , printfcmd }, |
9359 | #endif | 9359 | #endif |
9360 | { BUILTIN_NOSPEC "pwd" , pwdcmd }, | 9360 | { BUILTIN_NOSPEC "pwd" , pwdcmd }, |
@@ -9366,7 +9366,7 @@ static const struct builtincmd builtintab[] = { | |||
9366 | #if ENABLE_ASH_BASH_COMPAT | 9366 | #if ENABLE_ASH_BASH_COMPAT |
9367 | { BUILTIN_SPEC_REG "source" , dotcmd }, | 9367 | { BUILTIN_SPEC_REG "source" , dotcmd }, |
9368 | #endif | 9368 | #endif |
9369 | #if ENABLE_ASH_BUILTIN_TEST | 9369 | #if ENABLE_ASH_TEST |
9370 | { BUILTIN_REGULAR "test" , testcmd }, | 9370 | { BUILTIN_REGULAR "test" , testcmd }, |
9371 | #endif | 9371 | #endif |
9372 | { BUILTIN_SPEC_REG "times" , timescmd }, | 9372 | { BUILTIN_SPEC_REG "times" , timescmd }, |
@@ -9385,15 +9385,15 @@ static const struct builtincmd builtintab[] = { | |||
9385 | /* Should match the above table! */ | 9385 | /* Should match the above table! */ |
9386 | #define COMMANDCMD (builtintab + \ | 9386 | #define COMMANDCMD (builtintab + \ |
9387 | /* . : */ 2 + \ | 9387 | /* . : */ 2 + \ |
9388 | /* [ */ 1 * ENABLE_ASH_BUILTIN_TEST + \ | 9388 | /* [ */ 1 * ENABLE_ASH_TEST + \ |
9389 | /* [[ */ 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \ | 9389 | /* [[ */ 1 * ENABLE_ASH_TEST * ENABLE_ASH_BASH_COMPAT + \ |
9390 | /* alias */ 1 * ENABLE_ASH_ALIAS + \ | 9390 | /* alias */ 1 * ENABLE_ASH_ALIAS + \ |
9391 | /* bg */ 1 * ENABLE_ASH_JOB_CONTROL + \ | 9391 | /* bg */ 1 * ENABLE_ASH_JOB_CONTROL + \ |
9392 | /* break cd cddir */ 3) | 9392 | /* break cd cddir */ 3) |
9393 | #define EVALCMD (COMMANDCMD + \ | 9393 | #define EVALCMD (COMMANDCMD + \ |
9394 | /* command */ 1 * ENABLE_ASH_CMDCMD + \ | 9394 | /* command */ 1 * ENABLE_ASH_CMDCMD + \ |
9395 | /* continue */ 1 + \ | 9395 | /* continue */ 1 + \ |
9396 | /* echo */ 1 * ENABLE_ASH_BUILTIN_ECHO + \ | 9396 | /* echo */ 1 * ENABLE_ASH_ECHO + \ |
9397 | 0) | 9397 | 0) |
9398 | #define EXECCMD (EVALCMD + \ | 9398 | #define EXECCMD (EVALCMD + \ |
9399 | /* eval */ 1) | 9399 | /* 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 @@ | |||
197 | //config: default y | 197 | //config: default y |
198 | //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH | 198 | //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH |
199 | //config: | 199 | //config: |
200 | //config:config HUSH_TEST | ||
201 | //config: bool "test builtin" | ||
202 | //config: default y | ||
203 | //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH | ||
204 | //config: | ||
200 | //config:config HUSH_HELP | 205 | //config:config HUSH_HELP |
201 | //config: bool "help builtin" | 206 | //config: bool "help builtin" |
202 | //config: default y | 207 | //config: default y |
@@ -942,7 +947,9 @@ static int builtin_set(char **argv) FAST_FUNC; | |||
942 | #endif | 947 | #endif |
943 | static int builtin_shift(char **argv) FAST_FUNC; | 948 | static int builtin_shift(char **argv) FAST_FUNC; |
944 | static int builtin_source(char **argv) FAST_FUNC; | 949 | static int builtin_source(char **argv) FAST_FUNC; |
950 | #if ENABLE_HUSH_TEST | ||
945 | static int builtin_test(char **argv) FAST_FUNC; | 951 | static int builtin_test(char **argv) FAST_FUNC; |
952 | #endif | ||
946 | #if ENABLE_HUSH_TRAP | 953 | #if ENABLE_HUSH_TRAP |
947 | static int builtin_trap(char **argv) FAST_FUNC; | 954 | static int builtin_trap(char **argv) FAST_FUNC; |
948 | #endif | 955 | #endif |
@@ -1061,7 +1068,9 @@ static const struct built_in_command bltins1[] = { | |||
1061 | #endif | 1068 | #endif |
1062 | }; | 1069 | }; |
1063 | static const struct built_in_command bltins2[] = { | 1070 | static const struct built_in_command bltins2[] = { |
1071 | #if ENABLE_HUSH_TEST | ||
1064 | BLTIN("[" , builtin_test , NULL), | 1072 | BLTIN("[" , builtin_test , NULL), |
1073 | #endif | ||
1065 | #if ENABLE_HUSH_ECHO | 1074 | #if ENABLE_HUSH_ECHO |
1066 | BLTIN("echo" , builtin_echo , NULL), | 1075 | BLTIN("echo" , builtin_echo , NULL), |
1067 | #endif | 1076 | #endif |
@@ -1069,7 +1078,9 @@ static const struct built_in_command bltins2[] = { | |||
1069 | BLTIN("printf" , builtin_printf , NULL), | 1078 | BLTIN("printf" , builtin_printf , NULL), |
1070 | #endif | 1079 | #endif |
1071 | BLTIN("pwd" , builtin_pwd , NULL), | 1080 | BLTIN("pwd" , builtin_pwd , NULL), |
1081 | #if ENABLE_HUSH_TEST | ||
1072 | BLTIN("test" , builtin_test , NULL), | 1082 | BLTIN("test" , builtin_test , NULL), |
1083 | #endif | ||
1073 | }; | 1084 | }; |
1074 | 1085 | ||
1075 | 1086 | ||
@@ -8791,6 +8802,7 @@ static int FAST_FUNC builtin_true(char **argv UNUSED_PARAM) | |||
8791 | return 0; | 8802 | return 0; |
8792 | } | 8803 | } |
8793 | 8804 | ||
8805 | #if ENABLE_HUSH_TEST || ENABLE_HUSH_ECHO || ENABLE_HUSH_PRINTF || ENABLE_HUSH_KILL | ||
8794 | static int run_applet_main(char **argv, int (*applet_main_func)(int argc, char **argv)) | 8806 | static int run_applet_main(char **argv, int (*applet_main_func)(int argc, char **argv)) |
8795 | { | 8807 | { |
8796 | int argc = 0; | 8808 | int argc = 0; |
@@ -8800,11 +8812,13 @@ static int run_applet_main(char **argv, int (*applet_main_func)(int argc, char * | |||
8800 | } | 8812 | } |
8801 | return applet_main_func(argc, argv - argc); | 8813 | return applet_main_func(argc, argv - argc); |
8802 | } | 8814 | } |
8803 | 8815 | #endif | |
8816 | #if ENABLE_HUSH_TEST | ||
8804 | static int FAST_FUNC builtin_test(char **argv) | 8817 | static int FAST_FUNC builtin_test(char **argv) |
8805 | { | 8818 | { |
8806 | return run_applet_main(argv, test_main); | 8819 | return run_applet_main(argv, test_main); |
8807 | } | 8820 | } |
8821 | #endif | ||
8808 | #if ENABLE_HUSH_ECHO | 8822 | #if ENABLE_HUSH_ECHO |
8809 | static int FAST_FUNC builtin_echo(char **argv) | 8823 | static int FAST_FUNC builtin_echo(char **argv) |
8810 | { | 8824 | { |