aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorpgf <pgf@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-06-08 21:37:26 +0000
committerpgf <pgf@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-06-08 21:37:26 +0000
commitdc3b7958d75c261b988db308963da8e85792ace7 (patch)
tree5f109ab555b2e3ca7df717cd7590058ab12d54c1 /shell
parent0b623f284cee0ef504cda61a8c8338c2acdb0082 (diff)
downloadbusybox-w32-dc3b7958d75c261b988db308963da8e85792ace7.tar.gz
busybox-w32-dc3b7958d75c261b988db308963da8e85792ace7.tar.bz2
busybox-w32-dc3b7958d75c261b988db308963da8e85792ace7.zip
made "test" an ash built-in.
moved the contents of libbb/bb_echo.c back into coreutils/echo.c, which is a more reasonable place for them than libbb. this forces anyone who wants echo and test to be builtin to ash to also have them available as applets. their cost is very small, and the number of people who wouldn't want them as applets is also very small. added warning about shell builtins vs. CONFIG_FEATURE_SH_STANDALONE_SHELL, which conflicts with their use. thanks to nathanael copa for debugging help. some string size optimization in test.c may have been lost with this commit, but this is a good new baseline. git-svn-id: svn://busybox.net/trunk/busybox@15344 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r--shell/Config.in38
-rw-r--r--shell/ash.c30
2 files changed, 49 insertions, 19 deletions
diff --git a/shell/Config.in b/shell/Config.in
index dde8fd1dd..8f2f98e68 100644
--- a/shell/Config.in
+++ b/shell/Config.in
@@ -95,12 +95,28 @@ config CONFIG_ASH_MATH_SUPPORT_64
95 large numbers. 95 large numbers.
96 96
97config CONFIG_ASH_GETOPTS 97config CONFIG_ASH_GETOPTS
98 bool "Enable getopts builtin to parse positional parameters" 98 bool "Builtin getopt to parse positional parameters"
99 default n 99 default n
100 depends on CONFIG_ASH 100 depends on CONFIG_ASH
101 help 101 help
102 Enable getopts builtin in the ash shell. 102 Enable getopts builtin in the ash shell.
103 103
104config CONFIG_ASH_BUILTIN_ECHO
105 bool "Builtin version of 'echo'"
106 default y
107 select CONFIG_ECHO
108 depends on CONFIG_ASH
109 help
110 Enable support for echo, built in to ash.
111
112config CONFIG_ASH_BUILTIN_TEST
113 bool "Builtin version of 'test'"
114 default y
115 select CONFIG_TEST
116 depends on CONFIG_ASH
117 help
118 Enable support for test, built in to ash.
119
104config CONFIG_ASH_CMDCMD 120config CONFIG_ASH_CMDCMD
105 bool "Enable cmdcmd to override shell builtins" 121 bool "Enable cmdcmd to override shell builtins"
106 default n 122 default n
@@ -110,21 +126,6 @@ config CONFIG_ASH_CMDCMD
110 you to run the specified command with the specified arguments, 126 you to run the specified command with the specified arguments,
111 even when there is an ash builtin command with the same name. 127 even when there is an ash builtin command with the same name.
112 128
113config CONFIG_ASH_BUILTIN_ECHO
114 bool "Enable builtin version of 'echo'"
115 default n
116 depends on CONFIG_ASH
117 help
118 Enable support for echo, built in to ash.
119
120# this entry also appears in coreutils/Config.in, next to the echo applet
121config CONFIG_FEATURE_FANCY_ECHO
122 bool "Enable echo options (-n and -e)"
123 default y
124 depends on CONFIG_ASH_BUILTIN_ECHO
125 help
126 This adds options (-n and -e) to echo.
127
128config CONFIG_ASH_MAIL 129config CONFIG_ASH_MAIL
129 bool "Check for new mail on interactive shells" 130 bool "Check for new mail on interactive shells"
130 default y 131 default y
@@ -229,6 +230,11 @@ config CONFIG_FEATURE_SH_STANDALONE_SHELL
229 is generally used when creating a statically linked version of busybox 230 is generally used when creating a statically linked version of busybox
230 for use as a rescue shell, in the event that you screw up your system. 231 for use as a rescue shell, in the event that you screw up your system.
231 232
233 Note that this will *also* cause applets to take precedence
234 over shell builtins of the same name. So turning this on will
235 eliminate any performance gained by turning on the builtin "echo"
236 and "test" commands in ash.
237
232 Note that when using this option, the shell will attempt to directly 238 Note that when using this option, the shell will attempt to directly
233 run '/bin/busybox'. If you do not have the busybox binary sitting in 239 run '/bin/busybox'. If you do not have the busybox binary sitting in
234 that exact location with that exact name, this option will not work at 240 that exact location with that exact name, this option will not work at
diff --git a/shell/ash.c b/shell/ash.c
index 962813dbd..713898a9f 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1225,6 +1225,9 @@ static int evalcmd(int, char **);
1225#ifdef CONFIG_ASH_BUILTIN_ECHO 1225#ifdef CONFIG_ASH_BUILTIN_ECHO
1226static int echocmd(int, char **); 1226static int echocmd(int, char **);
1227#endif 1227#endif
1228#ifdef CONFIG_ASH_BUILTIN_TEST
1229static int testcmd(int, char **);
1230#endif
1228static int execcmd(int, char **); 1231static int execcmd(int, char **);
1229static int exitcmd(int, char **); 1232static int exitcmd(int, char **);
1230static int exportcmd(int, char **); 1233static int exportcmd(int, char **);
@@ -1286,10 +1289,15 @@ struct builtincmd {
1286 1289
1287 1290
1288#define COMMANDCMD (builtincmd + 5 + \ 1291#define COMMANDCMD (builtincmd + 5 + \
1289 ENABLE_ASH_ALIAS + ENABLE_ASH_JOB_CONTROL) 1292 2 * ENABLE_ASH_BUILTIN_TEST + \
1293 ENABLE_ASH_ALIAS + \
1294 ENABLE_ASH_JOB_CONTROL)
1290#define EXECCMD (builtincmd + 7 + \ 1295#define EXECCMD (builtincmd + 7 + \
1291 ENABLE_ASH_CMDCMD + ENABLE_ASH_ALIAS + \ 1296 2 * ENABLE_ASH_BUILTIN_TEST + \
1292 ENABLE_ASH_BUILTIN_ECHO + ENABLE_ASH_JOB_CONTROL) 1297 ENABLE_ASH_ALIAS + \
1298 ENABLE_ASH_JOB_CONTROL + \
1299 ENABLE_ASH_CMDCMD + \
1300 ENABLE_ASH_BUILTIN_ECHO)
1293 1301
1294#define BUILTIN_NOSPEC "0" 1302#define BUILTIN_NOSPEC "0"
1295#define BUILTIN_SPECIAL "1" 1303#define BUILTIN_SPECIAL "1"
@@ -1307,6 +1315,10 @@ struct builtincmd {
1307static const struct builtincmd builtincmd[] = { 1315static const struct builtincmd builtincmd[] = {
1308 { BUILTIN_SPEC_REG ".", dotcmd }, 1316 { BUILTIN_SPEC_REG ".", dotcmd },
1309 { BUILTIN_SPEC_REG ":", truecmd }, 1317 { BUILTIN_SPEC_REG ":", truecmd },
1318#ifdef CONFIG_ASH_BUILTIN_TEST
1319 { BUILTIN_REGULAR "[", testcmd },
1320 { BUILTIN_REGULAR "[[", testcmd },
1321#endif
1310#ifdef CONFIG_ASH_ALIAS 1322#ifdef CONFIG_ASH_ALIAS
1311 { BUILTIN_REG_ASSG "alias", aliascmd }, 1323 { BUILTIN_REG_ASSG "alias", aliascmd },
1312#endif 1324#endif
@@ -1353,6 +1365,9 @@ static const struct builtincmd builtincmd[] = {
1353 { BUILTIN_SPEC_REG "set", setcmd }, 1365 { BUILTIN_SPEC_REG "set", setcmd },
1354 { BUILTIN_SPEC_REG "source", dotcmd }, 1366 { BUILTIN_SPEC_REG "source", dotcmd },
1355 { BUILTIN_SPEC_REG "shift", shiftcmd }, 1367 { BUILTIN_SPEC_REG "shift", shiftcmd },
1368#ifdef CONFIG_ASH_BUILTIN_TEST
1369 { BUILTIN_REGULAR "test", testcmd },
1370#endif
1356 { BUILTIN_SPEC_REG "times", timescmd }, 1371 { BUILTIN_SPEC_REG "times", timescmd },
1357 { BUILTIN_SPEC_REG "trap", trapcmd }, 1372 { BUILTIN_SPEC_REG "trap", trapcmd },
1358 { BUILTIN_REGULAR "true", truecmd }, 1373 { BUILTIN_REGULAR "true", truecmd },
@@ -8143,6 +8158,15 @@ echocmd(int argc, char **argv)
8143 return bb_echo(argc, argv); 8158 return bb_echo(argc, argv);
8144} 8159}
8145#endif 8160#endif
8161
8162#ifdef CONFIG_ASH_BUILTIN_TEST
8163static int
8164testcmd(int argc, char **argv)
8165{
8166 return bb_test(argc, argv);
8167}
8168#endif
8169
8146/* memalloc.c */ 8170/* memalloc.c */
8147 8171
8148/* 8172/*