aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-08-01 17:21:35 +0000
committerMatt Kraai <kraai@debian.org>2001-08-01 17:21:35 +0000
commit2d91deba45d5a284614e06cc55e2be03599ca26d (patch)
tree0ba0d2096b4305465ddea8532a5931cb4c02b343
parent00344431402703089c6b93f6119f9966cc7ba566 (diff)
downloadbusybox-w32-2d91deba45d5a284614e06cc55e2be03599ca26d.tar.gz
busybox-w32-2d91deba45d5a284614e06cc55e2be03599ca26d.tar.bz2
busybox-w32-2d91deba45d5a284614e06cc55e2be03599ca26d.zip
Allow multiple shells to be enabled.
-rw-r--r--Changelog1
-rw-r--r--Config.h73
-rw-r--r--Makefile4
-rw-r--r--README32
-rw-r--r--applets.h22
-rw-r--r--applets/usage.h6
-rw-r--r--ash.c4
-rw-r--r--debian/Config.h-deb73
-rw-r--r--debian/Config.h-static73
-rw-r--r--debian/Config.h-udeb73
-rw-r--r--hush.c8
-rw-r--r--include/applets.h22
-rw-r--r--include/usage.h6
-rw-r--r--lash.c2
-rw-r--r--msh.c4
-rw-r--r--sh.c48
-rw-r--r--shell/ash.c4
-rw-r--r--shell/hush.c8
-rw-r--r--shell/lash.c2
-rw-r--r--shell/msh.c4
-rw-r--r--usage.h6
21 files changed, 225 insertions, 250 deletions
diff --git a/Changelog b/Changelog
index 45005b589..632541744 100644
--- a/Changelog
+++ b/Changelog
@@ -42,6 +42,7 @@
42 -- Reworked rdate option handling (is now smaller). 42 -- Reworked rdate option handling (is now smaller).
43 -- Size reduction in ping 43 -- Size reduction in ping
44 -- Always write dd counts to stderr 44 -- Always write dd counts to stderr
45 -- Allow multiple shells to be enabled
45 * Aaron Lehmann 46 * Aaron Lehmann
46 -- slimmed down md5sum 47 -- slimmed down md5sum
47 -- contributed a nice new (hand written, not lex/yacc) Posix math 48 -- contributed a nice new (hand written, not lex/yacc) Posix math
diff --git a/Config.h b/Config.h
index 4523fbcab..831eb933a 100644
--- a/Config.h
+++ b/Config.h
@@ -9,6 +9,7 @@
9// BusyBox Applications 9// BusyBox Applications
10//#define BB_ADJTIMEX 10//#define BB_ADJTIMEX
11//#define BB_AR 11//#define BB_AR
12//#define BB_ASH
12#define BB_BASENAME 13#define BB_BASENAME
13#define BB_CAT 14#define BB_CAT
14#define BB_CHGRP 15#define BB_CHGRP
@@ -51,6 +52,7 @@
51#define BB_HEAD 52#define BB_HEAD
52//#define BB_HOSTID 53//#define BB_HOSTID
53//#define BB_HOSTNAME 54//#define BB_HOSTNAME
55//#define BB_HUSH
54#define BB_ID 56#define BB_ID
55//#define BB_IFCONFIG 57//#define BB_IFCONFIG
56#define BB_INIT 58#define BB_INIT
@@ -58,6 +60,7 @@
58#define BB_KILL 60#define BB_KILL
59#define BB_KILLALL 61#define BB_KILLALL
60#define BB_KLOGD 62#define BB_KLOGD
63//#define BB_LASH
61//#define BB_LENGTH 64//#define BB_LENGTH
62#define BB_LN 65#define BB_LN
63//#define BB_LOADACM 66//#define BB_LOADACM
@@ -78,6 +81,7 @@
78#define BB_MODPROBE 81#define BB_MODPROBE
79#define BB_MORE 82#define BB_MORE
80#define BB_MOUNT 83#define BB_MOUNT
84#define BB_MSH
81//#define BB_MT 85//#define BB_MT
82#define BB_MV 86#define BB_MV
83//#define BB_NC 87//#define BB_NC
@@ -101,7 +105,6 @@
101//#define BB_RPM2CPIO 105//#define BB_RPM2CPIO
102#define BB_SED 106#define BB_SED
103//#define BB_SETKEYCODES 107//#define BB_SETKEYCODES
104#define BB_SH
105#define BB_SLEEP 108#define BB_SLEEP
106#define BB_SORT 109#define BB_SORT
107//#define BB_STTY 110//#define BB_STTY
@@ -146,40 +149,12 @@
146// pretty/useful). 149// pretty/useful).
147// 150//
148// 151//
149// If you enabled BB_SH above, you may select one of the following shells. 152// If you enabled one or more of the shells, you may select which one
150// You can only select ONE of the following shells. Sorry. 153// should be run when sh is invoked:
151// 154//#define BB_FEATURE_SH_IS_ASH
152// lash is the very smallest shell (adds just 10k) and it is quite usable as 155//#define BB_FEATURE_SH_IS_HUSH
153// a command prompt, but it is not suitable for any but the most trivial 156//#define BB_FEATURE_SH_IS_LASH
154// scripting (such as an initrd that calls insmod a few times) since it does 157#define BB_FEATURE_SH_IS_MSH
155// not understand Bourne shell grammer. It does handle pipes, redirects, and
156// job control though. Adding in command editing makes it very nice
157// lightweight command prompt.
158//#define BB_FEATURE_LASH
159//
160// hush is also quite small (just 18k) and it has very complete Bourne shell
161// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
162// like for/do/done or case/esac and such. It also currently has a problem
163// with job control.
164//#define BB_FEATURE_HUSH
165//
166// msh: The minix shell (adds just 30k) is quite complete and handles things
167// like for/do/done, case/esac and all the things you expect a Bourne shell to
168// do. It is not always pedantically correct about Bourne shell grammer (try
169// running the shell testscript "tests/sh.testcases" on it and compare vs bash)
170// but for most things it works quite well. It also uses only vfork, so it can
171// be used on uClinux systems. This was only recently added, so there is still
172// room to shrink it further...
173#define BB_FEATURE_MSH
174//
175// ash: This adds about 60k in the default configuration and is the most
176// complete and most pedantically correct shell included with busybox. This
177// shell was also recently added, and several people (mainly Vladimir and Erik)
178// have been working on it. There are a number of configurable things at the
179// top of ash.c as well, so check those out if you want to tweak things. The
180// Posix math support is currently disabled (that bit of code was horrible) but
181// will be restored for the next BusyBox release.
182//#define BB_FEATURE_ASH
183// 158//
184// BusyBox will, by default, malloc space for its buffers. This costs code 159// BusyBox will, by default, malloc space for its buffers. This costs code
185// size for the call to xmalloc. You can use the following feature to have 160// size for the call to xmalloc. You can use the following feature to have
@@ -286,11 +261,11 @@
286#define BB_FEATURE_SORT_UNIQUE 261#define BB_FEATURE_SORT_UNIQUE
287// 262//
288// Enable command line editing in the shell. 263// Enable command line editing in the shell.
289// Only relevant if BB_SH is enabled. On by default. 264// Only relevant if a shell is enabled. On by default.
290#define BB_FEATURE_COMMAND_EDITING 265#define BB_FEATURE_COMMAND_EDITING
291// 266//
292// Enable tab completion in the shell. This is now working quite nicely. 267// Enable tab completion in the shell. This is now working quite nicely.
293// This feature adds a bit over 4k. Only relevant if BB_SH is enabled. 268// This feature adds a bit over 4k. Only relevant if a shell is enabled.
294#define BB_FEATURE_COMMAND_TAB_COMPLETION 269#define BB_FEATURE_COMMAND_TAB_COMPLETION
295// 270//
296// Attempts to match usernames in a ~-prefixed path 271// Attempts to match usernames in a ~-prefixed path
@@ -299,7 +274,7 @@
299//Allow the shell to invoke all the compiled in BusyBox applets as if they 274//Allow the shell to invoke all the compiled in BusyBox applets as if they
300//were shell builtins. Nice for staticly linking an emergency rescue shell, 275//were shell builtins. Nice for staticly linking an emergency rescue shell,
301//among other things. Off by default. 276//among other things. Off by default.
302// Only relevant if BB_SH is enabled. 277// Only relevant if a shell is enabled.
303//#define BB_FEATURE_SH_STANDALONE_SHELL 278//#define BB_FEATURE_SH_STANDALONE_SHELL
304// 279//
305//When this is enabled, busybox shell applets can be called using full path 280//When this is enabled, busybox shell applets can be called using full path
@@ -308,13 +283,13 @@
308//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_ 283//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
309//busybox. Some systems want this, others do not. Choose wisely. :-) This 284//busybox. Some systems want this, others do not. Choose wisely. :-) This
310//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled. 285//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
311// Only relevant if BB_SH is enabled. Off by default. 286// Only relevant if a shell is enabled. Off by default.
312//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN 287//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
313// 288//
314// Uncomment this option for a fancy shell prompt that includes the 289// Uncomment this option for a fancy shell prompt that includes the
315// current username and hostname. On systems that don't have usernames 290// current username and hostname. On systems that don't have usernames
316// or hostnames, this can look hideous. 291// or hostnames, this can look hideous.
317// Only relevant if BB_SH is enabled. 292// Only relevant if a shell is enabled.
318//#define BB_FEATURE_SH_FANCY_PROMPT 293//#define BB_FEATURE_SH_FANCY_PROMPT
319// 294//
320//Turn on extra fbset options 295//Turn on extra fbset options
@@ -435,8 +410,8 @@
435 #undef BB_KLOGD /* Uses daemon() */ 410 #undef BB_KLOGD /* Uses daemon() */
436 #undef BB_UPDATE /* Uses daemon() */ 411 #undef BB_UPDATE /* Uses daemon() */
437#endif 412#endif
438#if defined BB_SH 413#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
439 #if defined BB_FEATURE_COMMAND_EDITING 414 #if defined BB_FEATURE_COMMAND_EDITING
440 #define BB_CMDEDIT 415 #define BB_CMDEDIT
441 #else 416 #else
442 #undef BB_FEATURE_COMMAND_EDITING 417 #undef BB_FEATURE_COMMAND_EDITING
@@ -494,3 +469,17 @@
494 #define BB_LOGREAD 469 #define BB_LOGREAD
495 #endif 470 #endif
496#endif 471#endif
472//
473#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
474# define BB_SH
475# define shell_main ash_main
476#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
477# define BB_SH
478# define shell_main hush_main
479#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
480# define BB_SH
481# define shell_main lash_main
482#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
483# define BB_SH
484# define shell_main msh_main
485#endif
diff --git a/Makefile b/Makefile
index 88a7aa0df..287c3c834 100644
--- a/Makefile
+++ b/Makefile
@@ -349,7 +349,7 @@ busybox.links: busybox.mkll Config.h applets.h
349 - $(SHELL) $^ >$@ 349 - $(SHELL) $^ >$@
350 350
351nfsmount.o cmdedit.o: %.o: %.h 351nfsmount.o cmdedit.o: %.o: %.h
352sh.o: cmdedit.h 352ash.o hush.o lash.o msh.o: cmdedit.h
353$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile 353$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
354 $(CC) $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o 354 $(CC) $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
355 355
@@ -377,8 +377,6 @@ libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS)
377 377
378usage.o: usage.h 378usage.o: usage.h
379 379
380sh.o: sh.c lash.c hush.c msh.c ash.c
381
382libbb/loop.o: libbb/loop.h 380libbb/loop.o: libbb/loop.h
383 381
384libbb/loop.h: mk_loop_h.sh 382libbb/loop.h: mk_loop_h.sh
diff --git a/README b/README
index ae0215c47..4f806a0bf 100644
--- a/README
+++ b/README
@@ -51,6 +51,38 @@ Supported kernels:
51 51
52---------------- 52----------------
53 53
54Shells:
55
56lash is the very smallest shell (adds just 10k) and it is quite usable as
57a command prompt, but it is not suitable for any but the most trivial
58scripting (such as an initrd that calls insmod a few times) since it does
59not understand Bourne shell grammer. It does handle pipes, redirects, and
60job control though. Adding in command editing makes it very nice
61lightweight command prompt.
62
63hush is also quite small (just 18k) and it has very complete Bourne shell
64grammer. It handles if/then/else/fi just fine, but doesn't handle loops
65like for/do/done or case/esac and such. It also currently has a problem
66with job control.
67
68msh: The minix shell (adds just 30k) is quite complete and handles things
69like for/do/done, case/esac and all the things you expect a Bourne shell to
70do. It is not always pedantically correct about Bourne shell grammer (try
71running the shell testscript "tests/sh.testcases" on it and compare vs bash)
72but for most things it works quite well. It also uses only vfork, so it can
73be used on uClinux systems. This was only recently added, so there is still
74room to shrink it further...
75
76ash: This adds about 60k in the default configuration and is the most
77complete and most pedantically correct shell included with busybox. This
78shell was also recently added, and several people (mainly Vladimir and Erik)
79have been working on it. There are a number of configurable things at the
80top of ash.c as well, so check those out if you want to tweak things. The
81Posix math support is currently disabled (that bit of code was horrible) but
82will be restored for the next BusyBox release.
83
84----------------
85
54Getting help: 86Getting help:
55 87
56When you find you need help, you can check out the BusyBox mailing list 88When you find you need help, you can check out the BusyBox mailing list
diff --git a/applets.h b/applets.h
index 0786c39eb..184bce09b 100644
--- a/applets.h
+++ b/applets.h
@@ -52,6 +52,9 @@
52#ifdef BB_AR 52#ifdef BB_AR
53 APPLET(ar, ar_main, _BB_DIR_USR_BIN) 53 APPLET(ar, ar_main, _BB_DIR_USR_BIN)
54#endif 54#endif
55#ifdef BB_ASH
56 APPLET_NOUSAGE("ash", ash_main, _BB_DIR_BIN)
57#endif
55#ifdef BB_BASENAME 58#ifdef BB_BASENAME
56 APPLET(basename, basename_main, _BB_DIR_USR_BIN) 59 APPLET(basename, basename_main, _BB_DIR_USR_BIN)
57#endif 60#endif
@@ -185,6 +188,9 @@
185#ifdef BB_HOSTNAME 188#ifdef BB_HOSTNAME
186 APPLET(hostname, hostname_main, _BB_DIR_BIN) 189 APPLET(hostname, hostname_main, _BB_DIR_BIN)
187#endif 190#endif
191#ifdef BB_HUSH
192 APPLET_NOUSAGE("hush", hush_main, _BB_DIR_BIN)
193#endif
188#ifdef BB_ID 194#ifdef BB_ID
189 APPLET(id, id_main, _BB_DIR_USR_BIN) 195 APPLET(id, id_main, _BB_DIR_USR_BIN)
190#endif 196#endif
@@ -206,6 +212,9 @@
206#ifdef BB_KLOGD 212#ifdef BB_KLOGD
207 APPLET(klogd, klogd_main, _BB_DIR_SBIN) 213 APPLET(klogd, klogd_main, _BB_DIR_SBIN)
208#endif 214#endif
215#ifdef BB_LASH
216 APPLET(lash, lash_main, _BB_DIR_BIN)
217#endif
209#ifdef BB_LENGTH 218#ifdef BB_LENGTH
210 APPLET(length, length_main, _BB_DIR_USR_BIN) 219 APPLET(length, length_main, _BB_DIR_USR_BIN)
211#endif 220#endif
@@ -272,6 +281,9 @@
272#ifdef BB_MOUNT 281#ifdef BB_MOUNT
273 APPLET(mount, mount_main, _BB_DIR_BIN) 282 APPLET(mount, mount_main, _BB_DIR_BIN)
274#endif 283#endif
284#ifdef BB_MSH
285 APPLET_NOUSAGE("msh", msh_main, _BB_DIR_BIN)
286#endif
275#ifdef BB_MT 287#ifdef BB_MT
276 APPLET(mt, mt_main, _BB_DIR_BIN) 288 APPLET(mt, mt_main, _BB_DIR_BIN)
277#endif 289#endif
@@ -344,8 +356,14 @@
344#ifdef BB_SETKEYCODES 356#ifdef BB_SETKEYCODES
345 APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN) 357 APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
346#endif 358#endif
347#ifdef BB_SH 359#ifdef BB_FEATURE_SH_IS_ASH
348 APPLET(sh, shell_main, _BB_DIR_BIN) 360 APPLET_NOUSAGE("sh", ash_main, _BB_DIR_BIN)
361#elif defined(BB_FEATURE_SH_IS_HUSH)
362 APPLET_NOUSAGE("sh", hush_main, _BB_DIR_BIN)
363#elif defined(BB_FEATURE_SH_IS_LASH)
364 APPLET_NOUSAGE("sh", lash_main, _BB_DIR_BIN)
365#elif defined(BB_FEATURE_SH_IS_MSH)
366 APPLET_NOUSAGE("sh", msh_main, _BB_DIR_BIN)
349#endif 367#endif
350#ifdef BB_SLEEP 368#ifdef BB_SLEEP
351 APPLET(sleep, sleep_main, _BB_DIR_BIN) 369 APPLET(sleep, sleep_main, _BB_DIR_BIN)
diff --git a/applets/usage.h b/applets/usage.h
index 08da42b27..13759d23f 100644
--- a/applets/usage.h
+++ b/applets/usage.h
@@ -1365,12 +1365,12 @@
1365#define setkeycodes_example_usage \ 1365#define setkeycodes_example_usage \
1366 "$ setkeycodes e030 127\n" 1366 "$ setkeycodes e030 127\n"
1367 1367
1368#define sh_trivial_usage \ 1368#define lash_trivial_usage \
1369 "[FILE]...\n" \ 1369 "[FILE]...\n" \
1370 "or: sh -c command [args]..." 1370 "or: sh -c command [args]..."
1371#define sh_full_usage \ 1371#define lash_full_usage \
1372 "lash: The BusyBox LAme SHell (command interpreter)" 1372 "lash: The BusyBox LAme SHell (command interpreter)"
1373#define sh_notes_usage \ 1373#define lash_notes_usage \
1374"This command does not yet have proper documentation.\n" \ 1374"This command does not yet have proper documentation.\n" \
1375"\n" \ 1375"\n" \
1376"Use lash just as you would use any other shell. It properly handles pipes,\n" \ 1376"Use lash just as you would use any other shell. It properly handles pipes,\n" \
diff --git a/ash.c b/ash.c
index 15e1adb7c..b1aec6278 100644
--- a/ash.c
+++ b/ash.c
@@ -7638,7 +7638,7 @@ static void procargs (int, char **);
7638 */ 7638 */
7639 7639
7640int 7640int
7641shell_main(argc, argv) 7641ash_main(argc, argv)
7642 int argc; 7642 int argc;
7643 char **argv; 7643 char **argv;
7644{ 7644{
@@ -12874,7 +12874,7 @@ findvar(struct var **vpp, const char *name)
12874/* 12874/*
12875 * Copyright (c) 1999 Herbert Xu <herbert@debian.org> 12875 * Copyright (c) 1999 Herbert Xu <herbert@debian.org>
12876 * This file contains code for the times builtin. 12876 * This file contains code for the times builtin.
12877 * $Id: ash.c,v 1.15 2001/07/31 21:38:23 andersen Exp $ 12877 * $Id: ash.c,v 1.16 2001/08/01 17:21:33 kraai Exp $
12878 */ 12878 */
12879static int timescmd (int argc, char **argv) 12879static int timescmd (int argc, char **argv)
12880{ 12880{
diff --git a/debian/Config.h-deb b/debian/Config.h-deb
index 93f5597a0..020f89d81 100644
--- a/debian/Config.h-deb
+++ b/debian/Config.h-deb
@@ -9,6 +9,7 @@
9// BusyBox Applications 9// BusyBox Applications
10//#define BB_ADJTIMEX 10//#define BB_ADJTIMEX
11#define BB_AR 11#define BB_AR
12//#define BB_ASH
12#define BB_BASENAME 13#define BB_BASENAME
13#define BB_CAT 14#define BB_CAT
14#define BB_CHGRP 15#define BB_CHGRP
@@ -51,6 +52,7 @@
51#define BB_HEAD 52#define BB_HEAD
52//#define BB_HOSTID 53//#define BB_HOSTID
53//#define BB_HOSTNAME 54//#define BB_HOSTNAME
55//#define BB_HUSH
54#define BB_ID 56#define BB_ID
55//#define BB_IFCONFIG 57//#define BB_IFCONFIG
56#define BB_INIT 58#define BB_INIT
@@ -58,6 +60,7 @@
58#define BB_KILL 60#define BB_KILL
59#define BB_KILLALL 61#define BB_KILLALL
60#define BB_KLOGD 62#define BB_KLOGD
63//#define BB_LASH
61//#define BB_LENGTH 64//#define BB_LENGTH
62#define BB_LN 65#define BB_LN
63//#define BB_LOADACM 66//#define BB_LOADACM
@@ -78,6 +81,7 @@
78//#define BB_NC 81//#define BB_NC
79#define BB_MORE 82#define BB_MORE
80#define BB_MOUNT 83#define BB_MOUNT
84//#define BB_MSH
81//#define BB_MT 85//#define BB_MT
82#define BB_MV 86#define BB_MV
83//#define BB_NSLOOKUP 87//#define BB_NSLOOKUP
@@ -99,7 +103,6 @@
99//#define BB_RPM2CPIO 103//#define BB_RPM2CPIO
100#define BB_SED 104#define BB_SED
101//#define BB_SETKEYCODES 105//#define BB_SETKEYCODES
102//#define BB_SH
103#define BB_SLEEP 106#define BB_SLEEP
104#define BB_SORT 107#define BB_SORT
105//#define BB_STTY 108//#define BB_STTY
@@ -143,40 +146,12 @@
143// pretty/useful). 146// pretty/useful).
144// 147//
145// 148//
146// If you enabled BB_SH above, you may select one of the following shells. 149// If you enabled one or more of the shells, you may select which one
147// You can only select ONE of the following shells. Sorry. 150// should be run when sh is invoked:
148// 151//#define BB_FEATURE_SH_IS_ASH
149// lash is the very smallest shell (adds just 10k) and it is quite usable as a 152//#define BB_FEATURE_SH_IS_HUSH
150// command prompt, but it is not suitable for any but the most trivial scripting 153//#define BB_FEATURE_SH_IS_LASH
151// (such as an initrd that calls insmod a few times) since it does not 154#define BB_FEATURE_SH_IS_MSH
152// understand Bourne shell grammer. It does handle pipes, redirects, and job
153// control though. Adding in command editing makes it very nice lightweight
154// command prompt.
155//#define BB_FEATURE_LASH
156//
157// hush is also quite small (just 18k) and it has very complete Bourne shell
158// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
159// like for/do/done or case/esac and such. It also currently has a problem
160// with job control.
161//#define BB_FEATURE_HUSH
162//
163// msh: The minix shell (adds just 30k) is quite complete and handles things
164// like for/do/done, case/esac and all the things you expect a Bourne shell to
165// do. It is not always pedantically correct about Bourne shell grammer (try
166// running the shell testscript "tests/sh.testcases" on it and compare vs
167// bash) but for most things it works quite well. It also uses only vfork, so
168// it can be used on uClinux systems. This was only recently added, so there is
169// still room to shrink it further...
170#define BB_FEATURE_MSH
171//
172// ash: This adds about 60k in the default configuration and is the most
173// complete and most pedantically correct shell included with busybox. This
174// shell was also recently added, and several people (mainly Vladimir and Erik)
175// have been working on it. There are a number of configurable things at the
176// top of ash.c as well, so check those out if you want to tweak things. The
177// Posix math support is currently disabled (that bit of code was horrible) but
178// will be restored for the next BusyBox release.
179//#define BB_FEATURE_ASH
180// 155//
181// BusyBox will, by default, malloc space for its buffers. This costs code 156// BusyBox will, by default, malloc space for its buffers. This costs code
182// size for the call to xmalloc. You can use the following feature to have 157// size for the call to xmalloc. You can use the following feature to have
@@ -283,11 +258,11 @@
283#define BB_FEATURE_SORT_UNIQUE 258#define BB_FEATURE_SORT_UNIQUE
284// 259//
285// Enable command line editing in the shell. 260// Enable command line editing in the shell.
286// Only relevant if BB_SH is enabled. On by default. 261// Only relevant if a shell is enabled. On by default.
287#define BB_FEATURE_COMMAND_EDITING 262#define BB_FEATURE_COMMAND_EDITING
288// 263//
289// Enable tab completion in the shell. This is now working quite nicely. 264// Enable tab completion in the shell. This is now working quite nicely.
290// This feature adds a bit over 4k. Only relevant if BB_SH is enabled. 265// This feature adds a bit over 4k. Only relevant if a shell is enabled.
291#define BB_FEATURE_COMMAND_TAB_COMPLETION 266#define BB_FEATURE_COMMAND_TAB_COMPLETION
292// 267//
293// Attempts to match usernames in a ~-prefixed path 268// Attempts to match usernames in a ~-prefixed path
@@ -296,7 +271,7 @@
296//Allow the shell to invoke all the compiled in BusyBox applets as if they 271//Allow the shell to invoke all the compiled in BusyBox applets as if they
297//were shell builtins. Nice for staticly linking an emergency rescue shell, 272//were shell builtins. Nice for staticly linking an emergency rescue shell,
298//among other things. Off by default. 273//among other things. Off by default.
299// Only relevant if BB_SH is enabled. 274// Only relevant if a shell is enabled.
300//#define BB_FEATURE_SH_STANDALONE_SHELL 275//#define BB_FEATURE_SH_STANDALONE_SHELL
301// 276//
302//When this is enabled, busybox shell applets can be called using full path 277//When this is enabled, busybox shell applets can be called using full path
@@ -305,13 +280,13 @@
305//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_ 280//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
306//busybox. Some systems want this, others do not. Choose wisely. :-) This 281//busybox. Some systems want this, others do not. Choose wisely. :-) This
307//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled. 282//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
308// Only relevant if BB_SH is enabled. Off by default. 283// Only relevant if a shell is enabled. Off by default.
309//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN 284//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
310// 285//
311// Uncomment this option for a fancy shell prompt that includes the 286// Uncomment this option for a fancy shell prompt that includes the
312// current username and hostname. On systems that don't have usernames 287// current username and hostname. On systems that don't have usernames
313// or hostnames, this can look hideous. 288// or hostnames, this can look hideous.
314// Only relevant if BB_SH is enabled. 289// Only relevant if a shell is enabled.
315//#define BB_FEATURE_SH_FANCY_PROMPT 290//#define BB_FEATURE_SH_FANCY_PROMPT
316// 291//
317//Turn on extra fbset options 292//Turn on extra fbset options
@@ -416,8 +391,8 @@
416// Nothing beyond this point should ever be touched by 391// Nothing beyond this point should ever be touched by
417// mere mortals so leave this stuff alone. 392// mere mortals so leave this stuff alone.
418// 393//
419#if defined BB_SH 394#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
420 #if defined BB_FEATURE_COMMAND_EDITING 395 #if defined BB_FEATURE_COMMAND_EDITING
421 #define BB_CMDEDIT 396 #define BB_CMDEDIT
422 #else 397 #else
423 #undef BB_FEATURE_COMMAND_EDITING 398 #undef BB_FEATURE_COMMAND_EDITING
@@ -482,3 +457,17 @@
482 #define BB_LOGREAD 457 #define BB_LOGREAD
483 #endif 458 #endif
484#endif 459#endif
460//
461#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
462# define BB_SH
463# define shell_main ash_main
464#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
465# define BB_SH
466# define shell_main hush_main
467#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
468# define BB_SH
469# define shell_main lash_main
470#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
471# define BB_SH
472# define shell_main msh_main
473#endif
diff --git a/debian/Config.h-static b/debian/Config.h-static
index e049b5aa2..a538b1a63 100644
--- a/debian/Config.h-static
+++ b/debian/Config.h-static
@@ -9,6 +9,7 @@
9// BusyBox Applications 9// BusyBox Applications
10//#define BB_ADJTIMEX 10//#define BB_ADJTIMEX
11#define BB_AR 11#define BB_AR
12#define BB_ASH
12#define BB_BASENAME 13#define BB_BASENAME
13#define BB_CAT 14#define BB_CAT
14#define BB_CHGRP 15#define BB_CHGRP
@@ -51,6 +52,7 @@
51#define BB_HEAD 52#define BB_HEAD
52#define BB_HOSTID 53#define BB_HOSTID
53#define BB_HOSTNAME 54#define BB_HOSTNAME
55#define BB_HUSH
54#define BB_ID 56#define BB_ID
55#define BB_IFCONFIG 57#define BB_IFCONFIG
56#define BB_INIT 58#define BB_INIT
@@ -58,6 +60,7 @@
58#define BB_KILL 60#define BB_KILL
59#define BB_KILLALL 61#define BB_KILLALL
60#define BB_KLOGD 62#define BB_KLOGD
63#define BB_LASH
61#define BB_LENGTH 64#define BB_LENGTH
62#define BB_LN 65#define BB_LN
63#define BB_LOADACM 66#define BB_LOADACM
@@ -78,6 +81,7 @@
78#define BB_NC 81#define BB_NC
79#define BB_MORE 82#define BB_MORE
80#define BB_MOUNT 83#define BB_MOUNT
84#define BB_MSH
81#define BB_MT 85#define BB_MT
82#define BB_MV 86#define BB_MV
83#define BB_NSLOOKUP 87#define BB_NSLOOKUP
@@ -99,7 +103,6 @@
99#define BB_RPM2CPIO 103#define BB_RPM2CPIO
100#define BB_SED 104#define BB_SED
101#define BB_SETKEYCODES 105#define BB_SETKEYCODES
102#define BB_SH
103#define BB_SLEEP 106#define BB_SLEEP
104#define BB_SORT 107#define BB_SORT
105#define BB_STTY 108#define BB_STTY
@@ -143,40 +146,12 @@
143// pretty/useful). 146// pretty/useful).
144// 147//
145// 148//
146// If you enabled BB_SH above, you may select one of the following shells. 149// If you enabled one or more of the shells, you may select which one
147// You can only select ONE of the following shells. Sorry. 150// should be run when sh is invoked:
148// 151//#define BB_FEATURE_SH_IS_ASH
149// lash is the very smallest shell (adds just 10k) and it is quite usable as a 152//#define BB_FEATURE_SH_IS_HUSH
150// command prompt, but it is not suitable for any but the most trivial scripting 153//#define BB_FEATURE_SH_IS_LASH
151// (such as an initrd that calls insmod a few times) since it does not 154#define BB_FEATURE_SH_IS_MSH
152// understand Bourne shell grammer. It does handle pipes, redirects, and job
153// control though. Adding in command editing makes it very nice lightweight
154// command prompt.
155//#define BB_FEATURE_LASH
156//
157// hush is also quite small (just 18k) and it has very complete Bourne shell
158// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
159// like for/do/done or case/esac and such. It also currently has a problem
160// with job control.
161//#define BB_FEATURE_HUSH
162//
163// msh: The minix shell (adds just 30k) is quite complete and handles things
164// like for/do/done, case/esac and all the things you expect a Bourne shell to
165// do. It is not always pedantically correct about Bourne shell grammer (try
166// running the shell testscript "tests/sh.testcases" on it and compare vs
167// bash) but for most things it works quite well. It also uses only vfork, so
168// it can be used on uClinux systems. This was only recently added, so there is
169// still room to shrink it further...
170//#define BB_FEATURE_MSH
171//
172// ash: This adds about 60k in the default configuration and is the most
173// complete and most pedantically correct shell included with busybox. This
174// shell was also recently added, and several people (mainly Vladimir and Erik)
175// have been working on it. There are a number of configurable things at the
176// top of ash.c as well, so check those out if you want to tweak things. The
177// Posix math support is currently disabled (that bit of code was horrible) but
178// will be restored for the next BusyBox release.
179#define BB_FEATURE_ASH
180// 155//
181// BusyBox will, by default, malloc space for its buffers. This costs code 156// BusyBox will, by default, malloc space for its buffers. This costs code
182// size for the call to xmalloc. You can use the following feature to have 157// size for the call to xmalloc. You can use the following feature to have
@@ -283,11 +258,11 @@
283#define BB_FEATURE_SORT_UNIQUE 258#define BB_FEATURE_SORT_UNIQUE
284// 259//
285// Enable command line editing in the shell. 260// Enable command line editing in the shell.
286// Only relevant if BB_SH is enabled. On by default. 261// Only relevant if a shell is enabled. On by default.
287#define BB_FEATURE_COMMAND_EDITING 262#define BB_FEATURE_COMMAND_EDITING
288// 263//
289// Enable tab completion in the shell. This is now working quite nicely. 264// Enable tab completion in the shell. This is now working quite nicely.
290// This feature adds a bit over 4k. Only relevant if BB_SH is enabled. 265// This feature adds a bit over 4k. Only relevant if a shell is enabled.
291#define BB_FEATURE_COMMAND_TAB_COMPLETION 266#define BB_FEATURE_COMMAND_TAB_COMPLETION
292// 267//
293// Attempts to match usernames in a ~-prefixed path 268// Attempts to match usernames in a ~-prefixed path
@@ -296,7 +271,7 @@
296//Allow the shell to invoke all the compiled in BusyBox applets as if they 271//Allow the shell to invoke all the compiled in BusyBox applets as if they
297//were shell builtins. Nice for staticly linking an emergency rescue shell, 272//were shell builtins. Nice for staticly linking an emergency rescue shell,
298//among other things. Off by default. 273//among other things. Off by default.
299// Only relevant if BB_SH is enabled. 274// Only relevant if a shell is enabled.
300#define BB_FEATURE_SH_STANDALONE_SHELL 275#define BB_FEATURE_SH_STANDALONE_SHELL
301// 276//
302//When this is enabled, busybox shell applets can be called using full path 277//When this is enabled, busybox shell applets can be called using full path
@@ -305,13 +280,13 @@
305//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_ 280//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
306//busybox. Some systems want this, others do not. Choose wisely. :-) This 281//busybox. Some systems want this, others do not. Choose wisely. :-) This
307//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled. 282//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
308// Only relevant if BB_SH is enabled. Off by default. 283// Only relevant if a shell is enabled. Off by default.
309#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN 284#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
310// 285//
311// Uncomment this option for a fancy shell prompt that includes the 286// Uncomment this option for a fancy shell prompt that includes the
312// current username and hostname. On systems that don't have usernames 287// current username and hostname. On systems that don't have usernames
313// or hostnames, this can look hideous. 288// or hostnames, this can look hideous.
314// Only relevant if BB_SH is enabled. 289// Only relevant if a shell is enabled.
315#define BB_FEATURE_SH_FANCY_PROMPT 290#define BB_FEATURE_SH_FANCY_PROMPT
316// 291//
317//Turn on extra fbset options 292//Turn on extra fbset options
@@ -416,8 +391,8 @@
416// Nothing beyond this point should ever be touched by 391// Nothing beyond this point should ever be touched by
417// mere mortals so leave this stuff alone. 392// mere mortals so leave this stuff alone.
418// 393//
419#if defined BB_SH 394#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
420 #if defined BB_FEATURE_COMMAND_EDITING 395 #if defined BB_FEATURE_COMMAND_EDITING
421 #define BB_CMDEDIT 396 #define BB_CMDEDIT
422 #else 397 #else
423 #undef BB_FEATURE_COMMAND_EDITING 398 #undef BB_FEATURE_COMMAND_EDITING
@@ -482,3 +457,17 @@
482 #define BB_LOGREAD 457 #define BB_LOGREAD
483 #endif 458 #endif
484#endif 459#endif
460//
461#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
462# define BB_SH
463# define shell_main ash_main
464#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
465# define BB_SH
466# define shell_main hush_main
467#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
468# define BB_SH
469# define shell_main lash_main
470#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
471# define BB_SH
472# define shell_main msh_main
473#endif
diff --git a/debian/Config.h-udeb b/debian/Config.h-udeb
index dfc32f655..172d3dc75 100644
--- a/debian/Config.h-udeb
+++ b/debian/Config.h-udeb
@@ -9,6 +9,7 @@
9// BusyBox Applications 9// BusyBox Applications
10//#define BB_ADJTIMEX 10//#define BB_ADJTIMEX
11//#define BB_AR 11//#define BB_AR
12//#define BB_ASH
12#define BB_BASENAME 13#define BB_BASENAME
13#define BB_CAT 14#define BB_CAT
14#define BB_CHGRP 15#define BB_CHGRP
@@ -51,6 +52,7 @@
51#define BB_HEAD 52#define BB_HEAD
52//#define BB_HOSTID 53//#define BB_HOSTID
53//#define BB_HOSTNAME 54//#define BB_HOSTNAME
55//#define BB_HUSH
54#define BB_ID 56#define BB_ID
55//#define BB_IFCONFIG 57//#define BB_IFCONFIG
56#define BB_INIT 58#define BB_INIT
@@ -58,6 +60,7 @@
58#define BB_KILL 60#define BB_KILL
59#define BB_KILLALL 61#define BB_KILLALL
60#define BB_KLOGD 62#define BB_KLOGD
63//#define BB_LASH
61//#define BB_LENGTH 64//#define BB_LENGTH
62#define BB_LN 65#define BB_LN
63//#define BB_LOADACM 66//#define BB_LOADACM
@@ -78,6 +81,7 @@
78//#define BB_NC 81//#define BB_NC
79#define BB_MORE 82#define BB_MORE
80#define BB_MOUNT 83#define BB_MOUNT
84//#define BB_MSH
81//#define BB_MT 85//#define BB_MT
82#define BB_MV 86#define BB_MV
83//#define BB_NSLOOKUP 87//#define BB_NSLOOKUP
@@ -99,7 +103,6 @@
99//#define BB_RPM2CPIO 103//#define BB_RPM2CPIO
100#define BB_SED 104#define BB_SED
101//#define BB_SETKEYCODES 105//#define BB_SETKEYCODES
102//#define BB_SH
103#define BB_SLEEP 106#define BB_SLEEP
104#define BB_SORT 107#define BB_SORT
105//#define BB_STTY 108//#define BB_STTY
@@ -143,40 +146,12 @@
143// pretty/useful). 146// pretty/useful).
144// 147//
145// 148//
146// If you enabled BB_SH above, you may select one of the following shells. 149// If you enabled one or more of the shells, you may select which one
147// You can only select ONE of the following shells. Sorry. 150// should be run when sh is invoked:
148// 151//#define BB_FEATURE_SH_IS_ASH
149// lash is the very smallest shell (adds just 10k) and it is quite usable as a 152//#define BB_FEATURE_SH_IS_HUSH
150// command prompt, but it is not suitable for any but the most trivial scripting 153//#define BB_FEATURE_SH_IS_LASH
151// (such as an initrd that calls insmod a few times) since it does not 154#define BB_FEATURE_SH_IS_MSH
152// understand Bourne shell grammer. It does handle pipes, redirects, and job
153// control though. Adding in command editing makes it very nice lightweight
154// command prompt.
155//#define BB_FEATURE_LASH
156//
157// hush is also quite small (just 18k) and it has very complete Bourne shell
158// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
159// like for/do/done or case/esac and such. It also currently has a problem
160// with job control.
161//#define BB_FEATURE_HUSH
162//
163// msh: The minix shell (adds just 30k) is quite complete and handles things
164// like for/do/done, case/esac and all the things you expect a Bourne shell to
165// do. It is not always pedantically correct about Bourne shell grammer (try
166// running the shell testscript "tests/sh.testcases" on it and compare vs
167// bash) but for most things it works quite well. It also uses only vfork, so
168// it can be used on uClinux systems. This was only recently added, so there is
169// still room to shrink it further...
170#define BB_FEATURE_MSH
171//
172// ash: This adds about 60k in the default configuration and is the most
173// complete and most pedantically correct shell included with busybox. This
174// shell was also recently added, and several people (mainly Vladimir and Erik)
175// have been working on it. There are a number of configurable things at the
176// top of ash.c as well, so check those out if you want to tweak things. The
177// Posix math support is currently disabled (that bit of code was horrible) but
178// will be restored for the next BusyBox release.
179//#define BB_FEATURE_ASH
180// 155//
181// BusyBox will, by default, malloc space for its buffers. This costs code 156// BusyBox will, by default, malloc space for its buffers. This costs code
182// size for the call to xmalloc. You can use the following feature to have 157// size for the call to xmalloc. You can use the following feature to have
@@ -283,11 +258,11 @@
283#define BB_FEATURE_SORT_UNIQUE 258#define BB_FEATURE_SORT_UNIQUE
284// 259//
285// Enable command line editing in the shell. 260// Enable command line editing in the shell.
286// Only relevant if BB_SH is enabled. On by default. 261// Only relevant if a shell is enabled. On by default.
287#define BB_FEATURE_COMMAND_EDITING 262#define BB_FEATURE_COMMAND_EDITING
288// 263//
289// Enable tab completion in the shell. This is now working quite nicely. 264// Enable tab completion in the shell. This is now working quite nicely.
290// This feature adds a bit over 4k. Only relevant if BB_SH is enabled. 265// This feature adds a bit over 4k. Only relevant if a shell is enabled.
291#define BB_FEATURE_COMMAND_TAB_COMPLETION 266#define BB_FEATURE_COMMAND_TAB_COMPLETION
292// 267//
293// Attempts to match usernames in a ~-prefixed path 268// Attempts to match usernames in a ~-prefixed path
@@ -296,7 +271,7 @@
296//Allow the shell to invoke all the compiled in BusyBox applets as if they 271//Allow the shell to invoke all the compiled in BusyBox applets as if they
297//were shell builtins. Nice for staticly linking an emergency rescue shell, 272//were shell builtins. Nice for staticly linking an emergency rescue shell,
298//among other things. Off by default. 273//among other things. Off by default.
299// Only relevant if BB_SH is enabled. 274// Only relevant if a shell is enabled.
300//#define BB_FEATURE_SH_STANDALONE_SHELL 275//#define BB_FEATURE_SH_STANDALONE_SHELL
301// 276//
302//When this is enabled, busybox shell applets can be called using full path 277//When this is enabled, busybox shell applets can be called using full path
@@ -305,13 +280,13 @@
305//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_ 280//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
306//busybox. Some systems want this, others do not. Choose wisely. :-) This 281//busybox. Some systems want this, others do not. Choose wisely. :-) This
307//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled. 282//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
308// Only relevant if BB_SH is enabled. Off by default. 283// Only relevant if a shell is enabled. Off by default.
309//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN 284//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
310// 285//
311// Uncomment this option for a fancy shell prompt that includes the 286// Uncomment this option for a fancy shell prompt that includes the
312// current username and hostname. On systems that don't have usernames 287// current username and hostname. On systems that don't have usernames
313// or hostnames, this can look hideous. 288// or hostnames, this can look hideous.
314// Only relevant if BB_SH is enabled. 289// Only relevant if a shell is enabled.
315//#define BB_FEATURE_SH_FANCY_PROMPT 290//#define BB_FEATURE_SH_FANCY_PROMPT
316// 291//
317//Turn on extra fbset options 292//Turn on extra fbset options
@@ -416,8 +391,8 @@
416// Nothing beyond this point should ever be touched by 391// Nothing beyond this point should ever be touched by
417// mere mortals so leave this stuff alone. 392// mere mortals so leave this stuff alone.
418// 393//
419#if defined BB_SH 394#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
420 #if defined BB_FEATURE_COMMAND_EDITING 395 #if defined BB_FEATURE_COMMAND_EDITING
421 #define BB_CMDEDIT 396 #define BB_CMDEDIT
422 #else 397 #else
423 #undef BB_FEATURE_COMMAND_EDITING 398 #undef BB_FEATURE_COMMAND_EDITING
@@ -482,3 +457,17 @@
482 #define BB_LOGREAD 457 #define BB_LOGREAD
483 #endif 458 #endif
484#endif 459#endif
460//
461#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
462# define BB_SH
463# define shell_main ash_main
464#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
465# define BB_SH
466# define shell_main hush_main
467#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
468# define BB_SH
469# define shell_main lash_main
470#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
471# define BB_SH
472# define shell_main msh_main
473#endif
diff --git a/hush.c b/hush.c
index 134404251..0e619f80e 100644
--- a/hush.c
+++ b/hush.c
@@ -112,7 +112,7 @@
112#else 112#else
113#define applet_name "hush" 113#define applet_name "hush"
114#include "standalone.h" 114#include "standalone.h"
115#define shell_main main 115#define hush_main main
116#undef BB_FEATURE_SH_FANCY_PROMPT 116#undef BB_FEATURE_SH_FANCY_PROMPT
117#endif 117#endif
118 118
@@ -2562,7 +2562,7 @@ static void setup_job_control()
2562 tcsetpgrp(shell_terminal, shell_pgrp); 2562 tcsetpgrp(shell_terminal, shell_pgrp);
2563} 2563}
2564 2564
2565int shell_main(int argc, char **argv) 2565int hush_main(int argc, char **argv)
2566{ 2566{
2567 int opt; 2567 int opt;
2568 FILE *input; 2568 FILE *input;
@@ -2572,8 +2572,8 @@ int shell_main(int argc, char **argv)
2572 global_argc = argc; 2572 global_argc = argc;
2573 global_argv = argv; 2573 global_argv = argv;
2574 2574
2575 /* (re?) initialize globals. Sometimes shell_main() ends up calling 2575 /* (re?) initialize globals. Sometimes hush_main() ends up calling
2576 * shell_main(), therefore we cannot rely on the BSS to zero out this 2576 * hush_main(), therefore we cannot rely on the BSS to zero out this
2577 * stuff. Reset these to 0 every time. */ 2577 * stuff. Reset these to 0 every time. */
2578 ifs = NULL; 2578 ifs = NULL;
2579 /* map[] is taken care of with call to update_ifs_map() */ 2579 /* map[] is taken care of with call to update_ifs_map() */
diff --git a/include/applets.h b/include/applets.h
index 0786c39eb..184bce09b 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -52,6 +52,9 @@
52#ifdef BB_AR 52#ifdef BB_AR
53 APPLET(ar, ar_main, _BB_DIR_USR_BIN) 53 APPLET(ar, ar_main, _BB_DIR_USR_BIN)
54#endif 54#endif
55#ifdef BB_ASH
56 APPLET_NOUSAGE("ash", ash_main, _BB_DIR_BIN)
57#endif
55#ifdef BB_BASENAME 58#ifdef BB_BASENAME
56 APPLET(basename, basename_main, _BB_DIR_USR_BIN) 59 APPLET(basename, basename_main, _BB_DIR_USR_BIN)
57#endif 60#endif
@@ -185,6 +188,9 @@
185#ifdef BB_HOSTNAME 188#ifdef BB_HOSTNAME
186 APPLET(hostname, hostname_main, _BB_DIR_BIN) 189 APPLET(hostname, hostname_main, _BB_DIR_BIN)
187#endif 190#endif
191#ifdef BB_HUSH
192 APPLET_NOUSAGE("hush", hush_main, _BB_DIR_BIN)
193#endif
188#ifdef BB_ID 194#ifdef BB_ID
189 APPLET(id, id_main, _BB_DIR_USR_BIN) 195 APPLET(id, id_main, _BB_DIR_USR_BIN)
190#endif 196#endif
@@ -206,6 +212,9 @@
206#ifdef BB_KLOGD 212#ifdef BB_KLOGD
207 APPLET(klogd, klogd_main, _BB_DIR_SBIN) 213 APPLET(klogd, klogd_main, _BB_DIR_SBIN)
208#endif 214#endif
215#ifdef BB_LASH
216 APPLET(lash, lash_main, _BB_DIR_BIN)
217#endif
209#ifdef BB_LENGTH 218#ifdef BB_LENGTH
210 APPLET(length, length_main, _BB_DIR_USR_BIN) 219 APPLET(length, length_main, _BB_DIR_USR_BIN)
211#endif 220#endif
@@ -272,6 +281,9 @@
272#ifdef BB_MOUNT 281#ifdef BB_MOUNT
273 APPLET(mount, mount_main, _BB_DIR_BIN) 282 APPLET(mount, mount_main, _BB_DIR_BIN)
274#endif 283#endif
284#ifdef BB_MSH
285 APPLET_NOUSAGE("msh", msh_main, _BB_DIR_BIN)
286#endif
275#ifdef BB_MT 287#ifdef BB_MT
276 APPLET(mt, mt_main, _BB_DIR_BIN) 288 APPLET(mt, mt_main, _BB_DIR_BIN)
277#endif 289#endif
@@ -344,8 +356,14 @@
344#ifdef BB_SETKEYCODES 356#ifdef BB_SETKEYCODES
345 APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN) 357 APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
346#endif 358#endif
347#ifdef BB_SH 359#ifdef BB_FEATURE_SH_IS_ASH
348 APPLET(sh, shell_main, _BB_DIR_BIN) 360 APPLET_NOUSAGE("sh", ash_main, _BB_DIR_BIN)
361#elif defined(BB_FEATURE_SH_IS_HUSH)
362 APPLET_NOUSAGE("sh", hush_main, _BB_DIR_BIN)
363#elif defined(BB_FEATURE_SH_IS_LASH)
364 APPLET_NOUSAGE("sh", lash_main, _BB_DIR_BIN)
365#elif defined(BB_FEATURE_SH_IS_MSH)
366 APPLET_NOUSAGE("sh", msh_main, _BB_DIR_BIN)
349#endif 367#endif
350#ifdef BB_SLEEP 368#ifdef BB_SLEEP
351 APPLET(sleep, sleep_main, _BB_DIR_BIN) 369 APPLET(sleep, sleep_main, _BB_DIR_BIN)
diff --git a/include/usage.h b/include/usage.h
index 08da42b27..13759d23f 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1365,12 +1365,12 @@
1365#define setkeycodes_example_usage \ 1365#define setkeycodes_example_usage \
1366 "$ setkeycodes e030 127\n" 1366 "$ setkeycodes e030 127\n"
1367 1367
1368#define sh_trivial_usage \ 1368#define lash_trivial_usage \
1369 "[FILE]...\n" \ 1369 "[FILE]...\n" \
1370 "or: sh -c command [args]..." 1370 "or: sh -c command [args]..."
1371#define sh_full_usage \ 1371#define lash_full_usage \
1372 "lash: The BusyBox LAme SHell (command interpreter)" 1372 "lash: The BusyBox LAme SHell (command interpreter)"
1373#define sh_notes_usage \ 1373#define lash_notes_usage \
1374"This command does not yet have proper documentation.\n" \ 1374"This command does not yet have proper documentation.\n" \
1375"\n" \ 1375"\n" \
1376"Use lash just as you would use any other shell. It properly handles pipes,\n" \ 1376"Use lash just as you would use any other shell. It properly handles pipes,\n" \
diff --git a/lash.c b/lash.c
index 8f8609534..0af669116 100644
--- a/lash.c
+++ b/lash.c
@@ -1545,7 +1545,7 @@ static void setup_job_control()
1545 tcsetpgrp(shell_terminal, shell_pgrp); 1545 tcsetpgrp(shell_terminal, shell_pgrp);
1546} 1546}
1547 1547
1548int shell_main(int argc_l, char **argv_l) 1548int lash_main(int argc_l, char **argv_l)
1549{ 1549{
1550 int opt, interactive=FALSE; 1550 int opt, interactive=FALSE;
1551 FILE *input = stdin; 1551 FILE *input = stdin;
diff --git a/msh.c b/msh.c
index 8f046e794..92a0f8536 100644
--- a/msh.c
+++ b/msh.c
@@ -143,7 +143,7 @@ static int newfile(char *s);
143static char *findeq(char *cp); 143static char *findeq(char *cp);
144static char *cclass(char *p, int sub); 144static char *cclass(char *p, int sub);
145static void initarea(void); 145static void initarea(void);
146extern int shell_main(int argc, char **argv); 146extern int msh_main(int argc, char **argv);
147 147
148 148
149struct brkcon { 149struct brkcon {
@@ -692,7 +692,7 @@ static char * current_prompt;
692 */ 692 */
693 693
694 694
695extern int shell_main(int argc, char **argv) 695extern int msh_main(int argc, char **argv)
696{ 696{
697 register int f; 697 register int f;
698 register char *s; 698 register char *s;
diff --git a/sh.c b/sh.c
deleted file mode 100644
index f5c06b423..000000000
--- a/sh.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Shell wrapper file for busybox
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#include "Config.h"
22
23/* This is to make testing things a bit simpler (to avoid
24 * a full recompile) till we get the new build system in place */
25#if 0
26#undef BB_FEATURE_LASH
27#undef BB_FEATURE_HUSH
28#undef BB_FEATURE_MSH
29#define BB_FEATURE_ASH
30#endif
31
32#if defined BB_FEATURE_ASH
33#include "ash.c"
34#elif defined BB_FEATURE_MSH
35#include "msh.c"
36#elif defined BB_FEATURE_HUSH
37#include "hush.c"
38#elif defined BB_FEATURE_LASH
39#include "lash.c"
40#endif
41
42/*
43Local Variables:
44c-file-style: "linux"
45c-basic-offset: 4
46tab-width: 4
47End:
48*/
diff --git a/shell/ash.c b/shell/ash.c
index 15e1adb7c..b1aec6278 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7638,7 +7638,7 @@ static void procargs (int, char **);
7638 */ 7638 */
7639 7639
7640int 7640int
7641shell_main(argc, argv) 7641ash_main(argc, argv)
7642 int argc; 7642 int argc;
7643 char **argv; 7643 char **argv;
7644{ 7644{
@@ -12874,7 +12874,7 @@ findvar(struct var **vpp, const char *name)
12874/* 12874/*
12875 * Copyright (c) 1999 Herbert Xu <herbert@debian.org> 12875 * Copyright (c) 1999 Herbert Xu <herbert@debian.org>
12876 * This file contains code for the times builtin. 12876 * This file contains code for the times builtin.
12877 * $Id: ash.c,v 1.15 2001/07/31 21:38:23 andersen Exp $ 12877 * $Id: ash.c,v 1.16 2001/08/01 17:21:33 kraai Exp $
12878 */ 12878 */
12879static int timescmd (int argc, char **argv) 12879static int timescmd (int argc, char **argv)
12880{ 12880{
diff --git a/shell/hush.c b/shell/hush.c
index 134404251..0e619f80e 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -112,7 +112,7 @@
112#else 112#else
113#define applet_name "hush" 113#define applet_name "hush"
114#include "standalone.h" 114#include "standalone.h"
115#define shell_main main 115#define hush_main main
116#undef BB_FEATURE_SH_FANCY_PROMPT 116#undef BB_FEATURE_SH_FANCY_PROMPT
117#endif 117#endif
118 118
@@ -2562,7 +2562,7 @@ static void setup_job_control()
2562 tcsetpgrp(shell_terminal, shell_pgrp); 2562 tcsetpgrp(shell_terminal, shell_pgrp);
2563} 2563}
2564 2564
2565int shell_main(int argc, char **argv) 2565int hush_main(int argc, char **argv)
2566{ 2566{
2567 int opt; 2567 int opt;
2568 FILE *input; 2568 FILE *input;
@@ -2572,8 +2572,8 @@ int shell_main(int argc, char **argv)
2572 global_argc = argc; 2572 global_argc = argc;
2573 global_argv = argv; 2573 global_argv = argv;
2574 2574
2575 /* (re?) initialize globals. Sometimes shell_main() ends up calling 2575 /* (re?) initialize globals. Sometimes hush_main() ends up calling
2576 * shell_main(), therefore we cannot rely on the BSS to zero out this 2576 * hush_main(), therefore we cannot rely on the BSS to zero out this
2577 * stuff. Reset these to 0 every time. */ 2577 * stuff. Reset these to 0 every time. */
2578 ifs = NULL; 2578 ifs = NULL;
2579 /* map[] is taken care of with call to update_ifs_map() */ 2579 /* map[] is taken care of with call to update_ifs_map() */
diff --git a/shell/lash.c b/shell/lash.c
index 8f8609534..0af669116 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -1545,7 +1545,7 @@ static void setup_job_control()
1545 tcsetpgrp(shell_terminal, shell_pgrp); 1545 tcsetpgrp(shell_terminal, shell_pgrp);
1546} 1546}
1547 1547
1548int shell_main(int argc_l, char **argv_l) 1548int lash_main(int argc_l, char **argv_l)
1549{ 1549{
1550 int opt, interactive=FALSE; 1550 int opt, interactive=FALSE;
1551 FILE *input = stdin; 1551 FILE *input = stdin;
diff --git a/shell/msh.c b/shell/msh.c
index 8f046e794..92a0f8536 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -143,7 +143,7 @@ static int newfile(char *s);
143static char *findeq(char *cp); 143static char *findeq(char *cp);
144static char *cclass(char *p, int sub); 144static char *cclass(char *p, int sub);
145static void initarea(void); 145static void initarea(void);
146extern int shell_main(int argc, char **argv); 146extern int msh_main(int argc, char **argv);
147 147
148 148
149struct brkcon { 149struct brkcon {
@@ -692,7 +692,7 @@ static char * current_prompt;
692 */ 692 */
693 693
694 694
695extern int shell_main(int argc, char **argv) 695extern int msh_main(int argc, char **argv)
696{ 696{
697 register int f; 697 register int f;
698 register char *s; 698 register char *s;
diff --git a/usage.h b/usage.h
index 08da42b27..13759d23f 100644
--- a/usage.h
+++ b/usage.h
@@ -1365,12 +1365,12 @@
1365#define setkeycodes_example_usage \ 1365#define setkeycodes_example_usage \
1366 "$ setkeycodes e030 127\n" 1366 "$ setkeycodes e030 127\n"
1367 1367
1368#define sh_trivial_usage \ 1368#define lash_trivial_usage \
1369 "[FILE]...\n" \ 1369 "[FILE]...\n" \
1370 "or: sh -c command [args]..." 1370 "or: sh -c command [args]..."
1371#define sh_full_usage \ 1371#define lash_full_usage \
1372 "lash: The BusyBox LAme SHell (command interpreter)" 1372 "lash: The BusyBox LAme SHell (command interpreter)"
1373#define sh_notes_usage \ 1373#define lash_notes_usage \
1374"This command does not yet have proper documentation.\n" \ 1374"This command does not yet have proper documentation.\n" \
1375"\n" \ 1375"\n" \
1376"Use lash just as you would use any other shell. It properly handles pipes,\n" \ 1376"Use lash just as you would use any other shell. It properly handles pipes,\n" \