diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-06 10:18:21 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-06 10:18:21 +0200 |
commit | 96f064d4161ed66d8db95bf8047eece90959f1e1 (patch) | |
tree | 14a9d1f501d6ddcc601d104c45a45d3e4c158b87 | |
parent | e09bff33412c150a2c4c80ca7e2d5c6b76f10c9f (diff) |
shell: remove lash and bbsh
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | TEST_config_nommu | 1 | ||||
-rw-r--r-- | TEST_config_noprintf | 1 | ||||
-rw-r--r-- | TEST_config_rh9 | 1 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | include/applets.src.h | 1 | ||||
-rw-r--r-- | shell/bbsh.c | 223 | ||||
-rw-r--r-- | shell/hush.c | 19 |
7 files changed, 1 insertions, 247 deletions
diff --git a/TEST_config_nommu b/TEST_config_nommu index 911f02f6b..18f448391 100644 --- a/TEST_config_nommu +++ b/TEST_config_nommu @@ -904,7 +904,6 @@ CONFIG_HUSH_FUNCTIONS=y CONFIG_HUSH_LOCAL=y CONFIG_HUSH_EXPORT_N=y CONFIG_HUSH_RANDOM_SUPPORT=y -CONFIG_LASH=y CONFIG_MSH=y CONFIG_SH_MATH_SUPPORT=y CONFIG_SH_MATH_SUPPORT_64=y diff --git a/TEST_config_noprintf b/TEST_config_noprintf index ba003a1fb..22525ecb6 100644 --- a/TEST_config_noprintf +++ b/TEST_config_noprintf @@ -904,7 +904,6 @@ CONFIG_FEATURE_SH_IS_NONE=y # CONFIG_FEATURE_BASH_IS_ASH is not set # CONFIG_FEATURE_BASH_IS_HUSH is not set CONFIG_FEATURE_BASH_IS_NONE=y -# CONFIG_LASH is not set # CONFIG_MSH is not set # CONFIG_SH_MATH_SUPPORT is not set # CONFIG_SH_MATH_SUPPORT_64 is not set diff --git a/TEST_config_rh9 b/TEST_config_rh9 index 3ffb1c6f3..e45608351 100644 --- a/TEST_config_rh9 +++ b/TEST_config_rh9 @@ -918,7 +918,6 @@ CONFIG_HUSH_FUNCTIONS=y CONFIG_HUSH_LOCAL=y CONFIG_HUSH_EXPORT_N=y CONFIG_HUSH_RANDOM_SUPPORT=y -# CONFIG_LASH is not set CONFIG_MSH=y CONFIG_SH_MATH_SUPPORT=y CONFIG_SH_MATH_SUPPORT_64=y @@ -82,7 +82,7 @@ Rob Landley suggested this: initramfs Busybox should have a sample initramfs build script. This depends on - bbsh, mdev, and switch_root. + shell, mdev, and switch_root. mkdep Write a mkdep that doesn't segfault if there's a directory it doesn't diff --git a/include/applets.src.h b/include/applets.src.h index 195598fee..0e4f966de 100644 --- a/include/applets.src.h +++ b/include/applets.src.h @@ -75,7 +75,6 @@ IF_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_DROP)) IF_AWK(APPLET_NOEXEC(awk, awk, _BB_DIR_USR_BIN, _BB_SUID_DROP, awk)) IF_BASENAME(APPLET_NOFORK(basename, basename, _BB_DIR_USR_BIN, _BB_SUID_DROP, basename)) IF_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_DROP)) -//IF_BBSH(APPLET(bbsh, _BB_DIR_BIN, _BB_SUID_DROP)) IF_BEEP(APPLET(beep, _BB_DIR_USR_BIN, _BB_SUID_DROP)) IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP)) IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP)) diff --git a/shell/bbsh.c b/shell/bbsh.c deleted file mode 100644 index 8e25db458..000000000 --- a/shell/bbsh.c +++ /dev/null @@ -1,223 +0,0 @@ -/* vi: set ts=4 : - * - * bbsh - busybox shell - * - * Copyright 2006 Rob Landley <rob@landley.net> - * - * Licensed under GPLv2 or later, see file LICENSE in this source tree. - */ - -// A section of code that gets repeatedly or conditionally executed is stored -// as a string and parsed each time it's run. - - - -// Wheee, debugging. - -// Terminal control -#define ENABLE_BBSH_TTY 0 - -// &, fg, bg, jobs. (ctrl-z with tty.) -#define ENABLE_BBSH_JOBCTL 0 - -// Flow control (if, while, for, functions { }) -#define ENABLE_BBSH_FLOWCTL 0 - -#define ENABLE_BBSH_ENVVARS 0 // Environment variable support - -// Local and synthetic variables, fancy prompts, set, $?, etc. -#define ENABLE_BBSH_LOCALVARS 0 - -// Pipes and redirects: | > < >> << && || & () ; -#define ENABLE_BBSH_PIPES 0 - -/* Fun: - - echo `echo hello#comment " woot` and more -*/ - -#include "libbb.h" - -// A single executable, its arguments, and other information we know about it. -#define BBSH_FLAG_EXIT 1 -#define BBSH_FLAG_SUSPEND 2 -#define BBSH_FLAG_PIPE 4 -#define BBSH_FLAG_AND 8 -#define BBSH_FLAG_OR 16 -#define BBSH_FLAG_AMP 32 -#define BBSH_FLAG_SEMI 64 -#define BBSH_FLAG_PAREN 128 - -// What we know about a single process. -struct command { - struct command *next; - int flags; // exit, suspend, && || - int pid; // pid (or exit code) - int argc; - char *argv[]; -}; - -// A collection of processes piped into/waiting on each other. -struct pipeline { - struct pipeline *next; - int job_id; - struct command *cmd; - char *cmdline; - int cmdlinelen; -}; - -static void free_list(void *list, void (*freeit)(void *data)) -{ - while (list) { - void **next = (void **)list; - void *list_next = *next; - freeit(list); - free(list); - list = list_next; - } -} - -// Parse one word from the command line, appending one or more argv[] entries -// to struct command. Handles environment variable substitution and -// substrings. Returns pointer to next used byte, or NULL if it -// hit an ending token. -static char *parse_word(char *start, struct command **cmd) -{ - char *end; - - // Detect end of line (and truncate line at comment) - if (ENABLE_BBSH_PIPES && strchr("><&|(;", *start)) return 0; - - // Grab next word. (Add dequote and envvar logic here) - end = start; - end = skip_non_whitespace(end); - (*cmd)->argv[(*cmd)->argc++] = xstrndup(start, end-start); - - // Allocate more space if there's no room for NULL terminator. - - if (!((*cmd)->argc & 7)) - *cmd = xrealloc(*cmd, - sizeof(struct command) + ((*cmd)->argc+8)*sizeof(char *)); - (*cmd)->argv[(*cmd)->argc] = 0; - return end; -} - -// Parse a line of text into a pipeline. -// Returns a pointer to the next line. - -static char *parse_pipeline(char *cmdline, struct pipeline *line) -{ - struct command **cmd = &(line->cmd); - char *start = line->cmdline = cmdline; - - if (!cmdline) return 0; - - if (ENABLE_BBSH_JOBCTL) line->cmdline = cmdline; - - // Parse command into argv[] - for (;;) { - char *end; - - // Skip leading whitespace and detect end of line. - start = skip_whitespace(start); - if (!*start || *start=='#') { - if (ENABLE_BBSH_JOBCTL) line->cmdlinelen = start-cmdline; - return 0; - } - - // Allocate next command structure if necessary - if (!*cmd) *cmd = xzalloc(sizeof(struct command)+8*sizeof(char *)); - - // Parse next argument and add the results to argv[] - end = parse_word(start, cmd); - - // If we hit the end of this command, how did it end? - if (!end) { - if (ENABLE_BBSH_PIPES && *start) { - if (*start==';') { - start++; - break; - } - // handle | & < > >> << || && - } - break; - } - start = end; - } - - if (ENABLE_BBSH_JOBCTL) line->cmdlinelen = start-cmdline; - - return start; -} - -// Execute the commands in a pipeline -static int run_pipeline(struct pipeline *line) -{ - struct command *cmd = line->cmd; - if (!cmd || !cmd->argc) return 0; - - // Handle local commands. This is totally fake and plastic. - if (cmd->argc==2 && !strcmp(cmd->argv[0],"cd")) - chdir(cmd->argv[1]); - else if (!strcmp(cmd->argv[0],"exit")) - exit(cmd->argc>1 ? atoi(cmd->argv[1]) : 0); - else { - int status; - pid_t pid=fork(); - if (!pid) { - run_applet_and_exit(cmd->argv[0],cmd->argc,cmd->argv); - execvp(cmd->argv[0],cmd->argv); - printf("No %s", cmd->argv[0]); - exit(EXIT_FAILURE); - } else waitpid(pid, &status, 0); - } - - return 0; -} - -static void free_cmd(void *data) -{ - struct command *cmd=(struct command *)data; - - while (cmd->argc) free(cmd->argv[--cmd->argc]); -} - - -static void handle(char *command) -{ - struct pipeline line; - char *start = command; - - for (;;) { - memset(&line,0,sizeof(struct pipeline)); - start = parse_pipeline(start, &line); - if (!line.cmd) break; - - run_pipeline(&line); - free_list(line.cmd, free_cmd); - } -} - -int bbsh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int bbsh_main(int argc UNUSED_PARAM, char **argv) -{ - char *command=NULL; - FILE *f; - - getopt32(argv, "c:", &command); - - f = argv[optind] ? xfopen_for_read(argv[optind]) : NULL; - if (command) handle(command); - else { - unsigned cmdlen=0; - for (;;) { - if (!f) putchar('$'); - if (1 > getline(&command, &cmdlen, f ? f : stdin)) break; - - handle(command); - } - if (ENABLE_FEATURE_CLEAN_UP) free(command); - } - - return 1; -} diff --git a/shell/hush.c b/shell/hush.c index 2afe12fea..81811cbb0 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -102,7 +102,6 @@ //applet:IF_HUSH(APPLET(hush, _BB_DIR_BIN, _BB_SUID_DROP)) //applet:IF_MSH(APPLET(msh, _BB_DIR_BIN, _BB_SUID_DROP)) -//applet:IF_LASH(APPLET(lash, _BB_DIR_BIN, _BB_SUID_DROP)) //applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, _BB_DIR_BIN, _BB_SUID_DROP, sh)) //applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, _BB_DIR_BIN, _BB_SUID_DROP, bash)) @@ -223,13 +222,6 @@ //config: This instructs hush to print commands before execution. //config: Adds ~300 bytes. //config: -//config:config LASH -//config: bool "lash (deprecated: aliased to hush)" -//config: default n -//config: select HUSH -//config: help -//config: lash is deprecated and will be removed, please migrate to hush. -//config: //config:config MSH //config: bool "msh (deprecated: aliased to hush)" //config: default n @@ -240,8 +232,6 @@ //usage:#define hush_trivial_usage NOUSAGE_STR //usage:#define hush_full_usage "" -//usage:#define lash_trivial_usage NOUSAGE_STR -//usage:#define lash_full_usage "" //usage:#define msh_trivial_usage NOUSAGE_STR //usage:#define msh_full_usage "" @@ -7732,15 +7722,6 @@ int hush_main(int argc, char **argv) } -#if ENABLE_LASH -int lash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int lash_main(int argc, char **argv) -{ - bb_error_msg("lash is deprecated, please use hush instead"); - return hush_main(argc, argv); -} -#endif - #if ENABLE_MSH int msh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int msh_main(int argc, char **argv) |