aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorGravatar Eric Andersen <andersen@codepoet.org>2001-10-24 05:00:29 +0000
committerGravatar Eric Andersen <andersen@codepoet.org>2001-10-24 05:00:29 +0000
commitbdfd0d78bc44e73d693510e70087857785b3b521 (patch)
tree153a573095afac8d8d0ea857759ecabd77fb28b7 /shell
parent9260fc5552a3ee52eb95823aa6689d52a1ffd33c (diff)
downloadbusybox-bdfd0d78bc44e73d693510e70087857785b3b521.tar.gz
busybox-bdfd0d78bc44e73d693510e70087857785b3b521.tar.bz2
Major rework of the directory structure and the entire build system.
-Erik
Diffstat (limited to 'shell')
-rw-r--r--shell/Makefile40
-rw-r--r--shell/ash.c34
-rw-r--r--shell/cmdedit.c94
-rw-r--r--shell/config.in51
-rw-r--r--shell/hush.c21
-rw-r--r--shell/lash.c38
-rw-r--r--shell/msh.c26
7 files changed, 199 insertions, 105 deletions
diff --git a/shell/Makefile b/shell/Makefile
new file mode 100644
index 000000000..e0229973e
--- /dev/null
+++ b/shell/Makefile
@@ -0,0 +1,40 @@
+# Makefile for busybox
+#
+# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+TOPDIR :=..
+L_TARGET := shell.a
+EXTRA_CFLAGS = -DBB_VER='"$(VERSION)"' -DBB_BT='"$(BUILDTIME)"'
+
+obj-y :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_ASH) += ash.o
+obj-$(CONFIG_HUSH) += hush.o
+obj-$(CONFIG_LASH) += lash.o
+obj-$(CONFIG_MSH) += msh.o
+obj-$(CONFIG_FEATURE_COMMAND_EDITING) += cmdedit.o
+
+
+# Hand off to toplevel Rules.mak
+include $(TOPDIR)/Rules.mak
+
+clean:
+ rm -f $(L_TARGET) *.o core
+
diff --git a/shell/ash.c b/shell/ash.c
index 486386a25..9cc2208ab 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -265,7 +265,7 @@ union align {
#define ALIGN(nbytes) (((nbytes) + sizeof(union align) - 1) & ~(sizeof(union align) - 1))
#endif
-#ifdef BB_LOCALE_SUPPORT
+#ifdef CONFIG_LOCALE_SUPPORT
#include <locale.h>
static void change_lc_all(const char *value);
static void change_lc_ctype(const char *value);
@@ -1218,7 +1218,7 @@ static struct var vpath;
static struct var vps1;
static struct var vps2;
static struct var voptind;
-#ifdef BB_LOCALE_SUPPORT
+#ifdef CONFIG_LOCALE_SUPPORT
static struct var vlc_all;
static struct var vlc_ctype;
#endif
@@ -1261,7 +1261,7 @@ static const struct varinit varinit[] = {
NULL },
{ &voptind, VSTRFIXED|VTEXTFIXED, "OPTIND=1",
getoptsreset },
-#ifdef BB_LOCALE_SUPPORT
+#ifdef CONFIG_LOCALE_SUPPORT
{ &vlc_all, VSTRFIXED|VTEXTFIXED|VUNSET, "LC_ALL=",
change_lc_all },
{ &vlc_ctype, VSTRFIXED|VTEXTFIXED|VUNSET, "LC_CTYPE=",
@@ -1556,7 +1556,7 @@ static int hashcmd (int, char **);
static int helpcmd (int, char **);
static int jobscmd (int, char **);
static int localcmd (int, char **);
-#ifndef BB_PWD
+#ifndef CONFIG_PWD
static int pwdcmd (int, char **);
#endif
static int readcmd (int, char **);
@@ -1582,7 +1582,7 @@ static int typecmd (int, char **);
static int getoptscmd (int, char **);
#endif
-#ifndef BB_TRUE_FALSE
+#ifndef CONFIG_TRUE_FALSE
static int true_main (int, char **);
static int false_main (int, char **);
#endif
@@ -1653,7 +1653,7 @@ static const struct builtincmd builtincmds[] = {
{ BUILTIN_REGULAR "let", letcmd },
#endif
{ BUILTIN_ASSIGN "local", localcmd },
-#ifndef BB_PWD
+#ifndef CONFIG_PWD
{ BUILTIN_NOSPEC "pwd", pwdcmd },
#endif
{ BUILTIN_REGULAR "read", readcmd },
@@ -1938,7 +1938,7 @@ updatepwd(const char *dir)
}
-#ifndef BB_PWD
+#ifndef CONFIG_PWD
static int
pwdcmd(argc, argv)
int argc;
@@ -3182,7 +3182,7 @@ returncmd(argc, argv)
}
-#ifndef BB_TRUE_FALSE
+#ifndef CONFIG_TRUE_FALSE
static int
false_main(argc, argv)
int argc;
@@ -3224,7 +3224,7 @@ setinteractive(int on)
is_interactive = on;
if (do_banner==0 && is_interactive) {
/* Looks like they want an interactive shell */
-#ifndef BB_FEATURE_SH_EXTRA_QUIET
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
printf( "\n\n" BB_BANNER " Built-in shell (ash)\n");
printf( "Enter 'help' for a list of built-in commands.\n\n");
#endif
@@ -3535,11 +3535,11 @@ tryexec(char *cmd, char **argv, char **envp)
{
int e;
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
char *name = cmd;
char** argv_l=argv;
int argc_l;
-#ifdef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
+#ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
name = get_last_path_component(name);
#endif
argv_l=envp;
@@ -3766,7 +3766,7 @@ static int helpcmd(int argc, char** argv)
col = 0;
}
}
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
{
extern const struct BB_applet applets[];
extern const size_t NUM_APPLETS;
@@ -6023,7 +6023,7 @@ reset(void) {
* This file implements the input routines used by the parser.
*/
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
static const char * cmdedit_prompt;
static inline void putprompt(const char *s) {
cmdedit_prompt = s;
@@ -6090,7 +6090,7 @@ preadfd(void)
parsenextc = buf;
retry:
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
{
if (!iflag || parsefile->fd)
nr = safe_read(parsefile->fd, buf, BUFSIZ - 1);
@@ -7718,7 +7718,7 @@ ash_main(argc, argv)
EXECCMD = find_builtin("exec");
EVALCMD = find_builtin("eval");
-#ifndef BB_FEATURE_SH_FANCY_PROMPT
+#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
unsetenv("PS1");
unsetenv("PS2");
#endif
@@ -9331,7 +9331,7 @@ getoptsreset(const char *value)
shellparam.optoff = -1;
}
-#ifdef BB_LOCALE_SUPPORT
+#ifdef CONFIG_LOCALE_SUPPORT
static void change_lc_all(const char *value)
{
if(value != 0 && *value != 0)
@@ -12730,7 +12730,7 @@ findvar(struct var **vpp, const char *name)
/*
* Copyright (c) 1999 Herbert Xu <herbert@debian.org>
* This file contains code for the times builtin.
- * $Id: ash.c,v 1.28 2001/10/19 00:22:22 andersen Exp $
+ * $Id: ash.c,v 1.29 2001/10/24 05:00:16 andersen Exp $
*/
static int timescmd (int argc, char **argv)
{
diff --git a/shell/cmdedit.c b/shell/cmdedit.c
index 16ec2f823..d1b9111ea 100644
--- a/shell/cmdedit.c
+++ b/shell/cmdedit.c
@@ -43,7 +43,7 @@
#include "busybox.h"
-#ifdef BB_LOCALE_SUPPORT
+#ifdef CONFIG_LOCALE_SUPPORT
#define Isprint(c) isprint((c))
#else
#define Isprint(c) ( (c) >= ' ' && (c) != ((unsigned char)'\233') )
@@ -55,32 +55,32 @@
#else
-#define BB_FEATURE_COMMAND_EDITING
-#define BB_FEATURE_COMMAND_TAB_COMPLETION
-#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
-#define BB_FEATURE_NONPRINTABLE_INVERSE_PUT
-#define BB_FEATURE_CLEAN_UP
+#define CONFIG_FEATURE_COMMAND_EDITING
+#define CONFIG_FEATURE_COMMAND_TAB_COMPLETION
+#define CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
+#define CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
+#define CONFIG_FEATURE_CLEAN_UP
#define D(x) x
#endif /* TEST */
-#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
#include <dirent.h>
#include <sys/stat.h>
#endif
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
-#ifndef BB_FEATURE_COMMAND_TAB_COMPLETION
-#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
+#ifndef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
+#undef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
#endif
-#if defined(BB_FEATURE_COMMAND_USERNAME_COMPLETION) || defined(BB_FEATURE_SH_FANCY_PROMPT)
-#define BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+#if defined(CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION) || defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
+#define CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
#endif
-#ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+#ifdef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
# ifndef TEST
# include "pwd_grp/pwd.h"
# else
@@ -136,33 +136,33 @@ static int cursor; /* required global for signal handler */
static int len; /* --- "" - - "" - -"- --""-- --""--- */
static char *command_ps; /* --- "" - - "" - -"- --""-- --""--- */
static
-#ifndef BB_FEATURE_SH_FANCY_PROMPT
+#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
const
#endif
char *cmdedit_prompt; /* --- "" - - "" - -"- --""-- --""--- */
-#ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+#ifdef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
static char *user_buf = "";
static char *home_pwd_buf = "";
static int my_euid;
#endif
-#ifdef BB_FEATURE_SH_FANCY_PROMPT
+#ifdef CONFIG_FEATURE_SH_FANCY_PROMPT
static char *hostname_buf = "";
static int num_ok_lines = 1;
#endif
-#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
-#ifndef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+#ifndef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
static int my_euid;
#endif
static int my_uid;
static int my_gid;
-#endif /* BB_FEATURE_COMMAND_TAB_COMPLETION */
+#endif /* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
/* It seems that libc5 doesn't know what a sighandler_t is... */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
@@ -207,7 +207,7 @@ static void cmdedit_reset_term(void)
handlers_sets &= ~SET_WCHG_HANDLERS;
}
fflush(stdout);
-#ifdef BB_FEATURE_CLEAN_UP
+#ifdef CONFIG_FEATURE_CLEAN_UP
if (his_front) {
struct history *n;
@@ -230,7 +230,7 @@ static void cmdedit_set_out_char(int next_char)
if (c == 0)
c = ' '; /* destroy end char? */
-#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
+#ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
if (!Isprint(c)) { /* Inverse put non-printable characters */
if (c >= 128)
c -= 128;
@@ -321,7 +321,7 @@ static void put_prompt(void)
cmdedit_y = 0; /* new quasireal y */
}
-#ifndef BB_FEATURE_SH_FANCY_PROMPT
+#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
static void parse_prompt(const char *prmt_ptr)
{
cmdedit_prompt = prmt_ptr;
@@ -359,7 +359,7 @@ static void parse_prompt(const char *prmt_ptr)
break;
c = *prmt_ptr++;
switch (c) {
-#ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+#ifdef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
case 'u':
pbuf = user_buf;
break;
@@ -382,7 +382,7 @@ static void parse_prompt(const char *prmt_ptr)
case '$':
c = my_euid == 0 ? '#' : '$';
break;
-#ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+#ifdef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
case 'w':
pbuf = pwd_buf;
l = strlen(home_pwd_buf);
@@ -526,7 +526,7 @@ static void cmdedit_init(void)
}
if ((handlers_sets & SET_ATEXIT) == 0) {
-#ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+#ifdef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
struct passwd *entry;
my_euid = geteuid();
@@ -537,20 +537,20 @@ static void cmdedit_init(void)
}
#endif
-#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
-#ifndef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
+#ifndef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
my_euid = geteuid();
#endif
my_uid = getuid();
my_gid = getgid();
-#endif /* BB_FEATURE_COMMAND_TAB_COMPLETION */
+#endif /* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
handlers_sets |= SET_ATEXIT;
atexit(cmdedit_reset_term); /* be sure to do this only once */
}
}
-#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
static int is_execute(const struct stat *st)
{
@@ -561,7 +561,7 @@ static int is_execute(const struct stat *st)
return FALSE;
}
-#ifdef BB_FEATURE_COMMAND_USERNAME_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
static char **username_tab_completion(char *ud, int *num_matches)
{
@@ -623,7 +623,7 @@ static char **username_tab_completion(char *ud, int *num_matches)
return (matches);
}
}
-#endif /* BB_FEATURE_COMMAND_USERNAME_COMPLETION */
+#endif /* CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION */
enum {
FIND_EXE_ONLY = 0,
@@ -720,7 +720,7 @@ static char **exe_n_cwd_tab_completion(char *command, int *num_matches,
strcpy(dirbuf, command);
/* set dir only */
dirbuf[(pfind - command) + 1] = 0;
-#ifdef BB_FEATURE_COMMAND_USERNAME_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
if (dirbuf[0] == '~') /* ~/... or ~user/... */
username_tab_completion(dirbuf, 0);
#endif
@@ -826,12 +826,12 @@ static int find_match(char *matchBuf, int *len_with_quotes)
collapse_pos(j, j + 1);
int_buf[j] |= QUOT;
i++;
-#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
+#ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
if (matchBuf[i] == '\t') /* algorithm equivalent */
int_buf[j] = ' ' | QUOT;
#endif
}
-#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
+#ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
else if (matchBuf[i] == '\t')
int_buf[j] = ' ';
#endif
@@ -1000,7 +1000,7 @@ static void input_tab(int *lastWasTab)
/* Free up any memory already allocated */
input_tab(0);
-#ifdef BB_FEATURE_COMMAND_USERNAME_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
/* If the word starts with `~' and there is no slash in the word,
* then try completing this word as a username. */
@@ -1119,7 +1119,7 @@ static void input_tab(int *lastWasTab)
}
}
}
-#endif /* BB_FEATURE_COMMAND_TAB_COMPLETION */
+#endif /* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
static void get_previous_history(struct history **hp, struct history *p)
{
@@ -1232,7 +1232,7 @@ int cmdedit_read_input(char *prompt, char command[BUFSIZ])
* if the len=0 and no chars to delete */
if (len == 0) {
prepare_to_die:
-#if !defined(BB_ASH)
+#if !defined(CONFIG_ASH)
printf("exit");
goto_new_line();
/* cmdedit_reset_term() called in atexit */
@@ -1259,7 +1259,7 @@ prepare_to_die:
input_backspace();
break;
case '\t':
-#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
input_tab(&lastWasTab);
#endif
break;
@@ -1299,7 +1299,7 @@ prepare_to_die:
goto prepare_to_die;
}
switch (c) {
-#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
+#ifdef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
case '\t': /* Alt-Tab */
input_tab(&lastWasTab);
@@ -1367,7 +1367,7 @@ prepare_to_die:
}
default: /* If it's regular input, do the normal thing */
-#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
+#ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
/* Control-V -- Add non-printable symbol */
if (c == 22) {
if (safe_read(0, &c, 1) < 1)
@@ -1457,7 +1457,7 @@ prepare_to_die:
history_counter++;
}
}
-#if defined(BB_FEATURE_SH_FANCY_PROMPT)
+#if defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
num_ok_lines++;
#endif
}
@@ -1465,10 +1465,10 @@ prepare_to_die:
command[len++] = '\n'; /* set '\n' */
command[len] = 0;
}
-#if defined(BB_FEATURE_CLEAN_UP) && defined(BB_FEATURE_COMMAND_TAB_COMPLETION)
+#if defined(CONFIG_FEATURE_CLEAN_UP) && defined(CONFIG_FEATURE_COMMAND_TAB_COMPLETION)
input_tab(0); /* strong free */
#endif
-#if defined(BB_FEATURE_SH_FANCY_PROMPT)
+#if defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
free(cmdedit_prompt);
#endif
cmdedit_reset_term();
@@ -1477,7 +1477,7 @@ prepare_to_die:
-#endif /* BB_FEATURE_COMMAND_EDITING */
+#endif /* CONFIG_FEATURE_COMMAND_EDITING */
#ifdef TEST
@@ -1485,7 +1485,7 @@ prepare_to_die:
const char *applet_name = "debug stuff usage";
const char *memory_exhausted = "Memory exhausted";
-#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
+#ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
#include <locale.h>
#endif
@@ -1493,7 +1493,7 @@ int main(int argc, char **argv)
{
char buff[BUFSIZ];
char *prompt =
-#if defined(BB_FEATURE_SH_FANCY_PROMPT)
+#if defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
"\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:\
\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] \
\\!\\[\\e[36;1m\\]\\$ \\[\\E[0m\\]";
@@ -1501,7 +1501,7 @@ int main(int argc, char **argv)
"% ";
#endif
-#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
+#ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
setlocale(LC_ALL, "");
#endif
while(1) {
diff --git a/shell/config.in b/shell/config.in
new file mode 100644
index 000000000..e33669a7b
--- /dev/null
+++ b/shell/config.in
@@ -0,0 +1,51 @@
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+mainmenu_option next_comment
+comment 'Bourne Shell'
+
+choice 'Choose your default shell' \
+ "ash CONFIG_FEATURE_SH_IS_ASH \
+ hush CONFIG_FEATURE_SH_IS_HUSH \
+ lash CONFIG_FEATURE_SH_IS_LASH \
+ msh CONFIG_FEATURE_SH_IS_MSH \
+ none CONFIG_FEATURE_SH_IS_NONE"
+
+if [ "$CONFIG_FEATURE_SH_IS_ASH" = "y" ] ; then
+ define_bool CONFIG_ASH y
+else
+ bool 'ash' CONFIG_ASH
+fi
+
+if [ "$CONFIG_FEATURE_SH_IS_HUSH" = "y" ] ; then
+ define_bool CONFIG_HUSH y
+else
+ bool 'hush' CONFIG_HUSH
+fi
+
+if [ "$CONFIG_FEATURE_SH_IS_LASH" = "y" ] ; then
+ define_bool CONFIG_LASH y
+else
+ bool 'lash' CONFIG_LASH
+fi
+
+if [ "$CONFIG_FEATURE_SH_IS_MSH" = "y" ] ; then
+ define_bool CONFIG_MSH y
+else
+ bool 'msh' CONFIG_MSH
+fi
+
+
+comment 'Bourne Shell Options'
+bool 'command line editing' CONFIG_FEATURE_COMMAND_EDITING
+bool 'tab completion' CONFIG_FEATURE_COMMAND_TAB_COMPLETION
+bool 'username completion' CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
+bool 'Standalone shell' CONFIG_FEATURE_SH_STANDALONE_SHELL
+bool 'Standalone shell -- applets always win' CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
+bool 'Fancy shell prompts' CONFIG_FEATURE_SH_FANCY_PROMPT
+bool 'Hide message on interactive shell startup' CONFIG_FEATURE_SH_EXTRA_QUIET
+
+endmenu
+
diff --git a/shell/hush.c b/shell/hush.c
index cb0e6e980..d37842b79 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -113,7 +113,8 @@
#define applet_name "hush"
#include "standalone.h"
#define hush_main main
-#undef BB_FEATURE_SH_FANCY_PROMPT
+#undef CONFIG_FEATURE_SH_FANCY_PROMPT
+#define BB_BANNER
#endif
typedef enum {
@@ -836,7 +837,7 @@ static int static_peek(struct in_str *i)
static inline void cmdedit_set_initial_prompt(void)
{
-#ifndef BB_FEATURE_SH_FANCY_PROMPT
+#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
PS1 = NULL;
#else
PS1 = getenv("PS1");
@@ -848,7 +849,7 @@ static inline void cmdedit_set_initial_prompt(void)
static inline void setup_prompt_string(int promptmode, char **prompt_str)
{
debug_printf("setup_prompt_string %d ",promptmode);
-#ifndef BB_FEATURE_SH_FANCY_PROMPT
+#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
/* Set up the prompt */
if (promptmode == 1) {
if (PS1)
@@ -871,7 +872,7 @@ static void get_user_input(struct in_str *i)
static char the_command[BUFSIZ];
setup_prompt_string(i->promptmode, &prompt_str);
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
/*
** enable command line editing only while a command line
** is actually being read; otherwise, we'll end up bequeathing
@@ -1085,18 +1086,18 @@ static void pseudo_exec(struct child_prog *child)
* really dislike relying on /proc for things. We could exec ourself
* from global_argv[0], but if we are in a chroot, we may not be able
* to find ourself... */
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
{
int argc_l;
char** argv_l=child->argv;
char *name = child->argv[0];
-#ifdef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
+#ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
/* Following discussions from November 2000 on the busybox mailing
* list, the default configuration, (without
* get_last_path_component()) lets the user force use of an
* external command by specifying the full (with slashes) filename.
- * If you enable BB_FEATURE_SH_APPLETS_ALWAYS_WIN, then applets
+ * If you enable CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN, then applets
* _aways_ override external commands, so if you want to run
* /bin/cat, it will use BusyBox cat even if /bin/cat exists on the
* filesystem and is _not_ busybox. Some systems may want this,
@@ -2586,7 +2587,7 @@ int hush_main(int argc, char **argv)
/* Initialize some more globals to non-zero values */
set_cwd();
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
cmdedit_set_initial_prompt();
#else
PS1 = NULL;
@@ -2655,7 +2656,7 @@ int hush_main(int argc, char **argv)
debug_printf("\ninteractive=%d\n", interactive);
if (interactive) {
/* Looks like they want an interactive shell */
-#ifndef BB_FEATURE_SH_EXTRA_QUIET
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
printf( "\n\n" BB_BANNER " hush - the humble shell v0.01 (testing)\n");
printf( "Enter 'help' for a list of built-in commands.\n\n");
#endif
@@ -2673,7 +2674,7 @@ int hush_main(int argc, char **argv)
input = xfopen(argv[optind], "r");
opt = parse_file_outer(input);
-#ifdef BB_FEATURE_CLEAN_UP
+#ifdef CONFIG_FEATURE_CLEAN_UP
fclose(input);
if (cwd && cwd != unknown)
free((char*)cwd);
diff --git a/shell/lash.c b/shell/lash.c
index ffdec8781..004d9495a 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -2,8 +2,8 @@
/*
* lash -- the BusyBox Lame-Ass SHell
*
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* Based in part on ladsh.c by Michael K. Johnson and Erik W. Troan, which is
* under the following liberal license: "We have placed this source code in the
@@ -25,8 +25,10 @@
*
*/
-/* This shell's parsing engine is officially at a dead-end.
- * Future work shell work should be done using hush.c
+/* This shell's parsing engine is officially at a dead-end. Future
+ * work shell work should be done using hush, msh, or ash. This is
+ * still a very useful, small shell -- it just don't need any more
+ * features beyond what it already has...
*/
//For debugging/development on the shell only...
@@ -48,7 +50,7 @@
#include "busybox.h"
#include "cmdedit.h"
-#ifdef BB_LOCALE_SUPPORT
+#ifdef CONFIG_LOCALE_SUPPORT
#include <locale.h>
#endif
@@ -390,12 +392,12 @@ static int builtin_export(struct child_prog *child)
res = putenv(v);
if (res)
fprintf(stderr, "export: %m\n");
-#ifdef BB_FEATURE_SH_FANCY_PROMPT
+#ifdef CONFIG_FEATURE_SH_FANCY_PROMPT
if (strncmp(v, "PS1=", 4)==0)
PS1 = getenv("PS1");
#endif
-#ifdef BB_LOCALE_SUPPORT
+#ifdef CONFIG_LOCALE_SUPPORT
if(strncmp(v, "LC_ALL=", 7)==0)
setlocale(LC_ALL, getenv("LC_ALL"));
if(strncmp(v, "LC_CTYPE=", 9)==0)
@@ -661,7 +663,7 @@ static void restore_redirects(int squirrel[])
static inline void cmdedit_set_initial_prompt(void)
{
-#ifndef BB_FEATURE_SH_FANCY_PROMPT
+#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
PS1 = NULL;
#else
PS1 = getenv("PS1");
@@ -672,7 +674,7 @@ static inline void cmdedit_set_initial_prompt(void)
static inline void setup_prompt_string(char **prompt_str)
{
-#ifndef BB_FEATURE_SH_FANCY_PROMPT
+#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
/* Set up the prompt */
if (shell_context == 0) {
if (PS1)
@@ -706,7 +708,7 @@ static int get_command(FILE * source, char *command)
if (source == stdin) {
setup_prompt_string(&prompt_str);
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
/*
** enable command line editing only while a command line
** is actually being read; otherwise, we'll end up bequeathing
@@ -1201,7 +1203,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg)
static int pseudo_exec(struct child_prog *child)
{
struct built_in_command *x;
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
char *name;
#endif
@@ -1223,7 +1225,7 @@ static int pseudo_exec(struct child_prog *child)
exit (x->function(child));
}
}
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
/* Check if the command matches any busybox internal
* commands ("applets") here. Following discussions from
* November 2000 on busybox@opensource.lineo.com, don't use
@@ -1237,8 +1239,8 @@ static int pseudo_exec(struct child_prog *child)
*/
name = child->argv[0];
-#ifdef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
- /* If you enable BB_FEATURE_SH_APPLETS_ALWAYS_WIN, then
+#ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
+ /* If you enable CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN, then
* if you run /bin/cat, it will use BusyBox cat even if
* /bin/cat exists on the filesystem and is _not_ busybox.
* Some systems want this, others do not. Choose wisely. :-)
@@ -1504,7 +1506,7 @@ static int busy_loop(FILE * input)
}
-#ifdef BB_FEATURE_CLEAN_UP
+#ifdef CONFIG_FEATURE_CLEAN_UP
void free_memory(void)
{
if (cwd && cwd!=unknown) {
@@ -1611,7 +1613,7 @@ int lash_main(int argc_l, char **argv_l)
if (interactive==TRUE) {
//printf( "optind=%d argv[optind]='%s'\n", optind, argv[optind]);
/* Looks like they want an interactive shell */
-#ifndef BB_FEATURE_SH_EXTRA_QUIET
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
printf( "\n\n" BB_BANNER " Built-in shell (lash)\n");
printf( "Enter 'help' for a list of built-in commands.\n\n");
#endif
@@ -1626,11 +1628,11 @@ int lash_main(int argc_l, char **argv_l)
if (!cwd)
cwd = unknown;
-#ifdef BB_FEATURE_CLEAN_UP
+#ifdef CONFIG_FEATURE_CLEAN_UP
atexit(free_memory);
#endif
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
cmdedit_set_initial_prompt();
#else
PS1 = NULL;
diff --git a/shell/msh.c b/shell/msh.c
index 5c4ec1019..a2f98c837 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -681,7 +681,7 @@ static void * brktop;
static void * brkaddr;
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
static char * current_prompt;
#endif
@@ -732,7 +732,7 @@ extern int msh_main(int argc, char **argv)
setval(ifs, " \t\n");
prompt = lookup("PS1");
-#ifdef BB_FEATURE_SH_FANCY_PROMPT
+#ifdef CONFIG_FEATURE_SH_FANCY_PROMPT
if (prompt->value == null)
#endif
setval(prompt, "$ ");
@@ -741,7 +741,7 @@ extern int msh_main(int argc, char **argv)
prompt->status &= ~EXPORT;
}
cprompt = lookup("PS2");
-#ifdef BB_FEATURE_SH_FANCY_PROMPT
+#ifdef CONFIG_FEATURE_SH_FANCY_PROMPT
if (cprompt->value == null)
#endif
setval(cprompt, "> ");
@@ -801,7 +801,7 @@ extern int msh_main(int argc, char **argv)
PUSHIO(afile, 0, iof);
if (isatty(0) && isatty(1) && !cflag) {
interactive++;
-#ifndef BB_FEATURE_SH_EXTRA_QUIET
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
printf( "\n\n" BB_BANNER " Built-in shell (msh)\n");
printf( "Enter 'help' for a list of built-in commands.\n\n");
#endif
@@ -835,7 +835,7 @@ extern int msh_main(int argc, char **argv)
for (;;) {
if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=prompt->value;
#else
prs(prompt->value);
@@ -2171,7 +2171,7 @@ loop:
startl = 1;
if (multiline || cf & CONTIN) {
if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=cprompt->value;
#else
prs(cprompt->value);
@@ -2224,7 +2224,7 @@ register int c, c1;
return(YYERRCODE);
}
if (interactive && c == '\n' && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=cprompt->value;
#else
prs(cprompt->value);
@@ -2838,9 +2838,9 @@ char *c, **v, **envp;
register char *sp, *tp;
int eacces = 0, asis = 0;
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
char *name = c;
-#ifdef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
+#ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
name = get_last_path_component(name);
#endif
optind = 1;
@@ -2960,7 +2960,7 @@ static int dohelp()
col = 0;
}
}
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
{
int i;
const struct BB_applet *applet;
@@ -4256,7 +4256,7 @@ readc()
if (multiline)
return e.iop->prev = 0;
if (interactive && e.iop == iostack+1) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=prompt->value;
#else
prs(prompt->value);
@@ -4462,7 +4462,7 @@ register struct ioarg *ap;
return *bp->bufp++ & 0177;
}
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
if (interactive) {
static char mycommand[BUFSIZ];
static int position = 0, size = 0;
@@ -4721,7 +4721,7 @@ int ec;
e.iobase = e.iop;
for (;;) {
if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=cprompt->value;
#else
prs(cprompt->value);