summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorPaul Fox2005-08-09 19:38:05 +0000
committerPaul Fox2005-08-09 19:38:05 +0000
commit0b62158475ecbfce16fb857042ec7f402d7594ec (patch)
treed5f722c5d16a204996e46c84e8fe7923f8f40abf /shell
parent3f11b1bf634536cb01d9913d1a3d10da5bf24541 (diff)
downloadbusybox-0b62158475ecbfce16fb857042ec7f402d7594ec.zip
busybox-0b62158475ecbfce16fb857042ec7f402d7594ec.tar.gz
implemented a builtin echo command in ash. moved the guts of the
echo applet into libbb, and now call bb_echo() from both echo.c and ash.c
Diffstat (limited to 'shell')
-rw-r--r--shell/Config.in15
-rw-r--r--shell/ash.c52
2 files changed, 34 insertions, 33 deletions
diff --git a/shell/Config.in b/shell/Config.in
index 0d39e5b..813044e 100644
--- a/shell/Config.in
+++ b/shell/Config.in
@@ -103,6 +103,21 @@ config CONFIG_ASH_CMDCMD
you to run the specified command with the specified arguments,
even when there is an ash builtin command with the same name.
+config CONFIG_ASH_BUILTIN_ECHO
+ bool " Enable builtin version of 'echo'"
+ default n
+ depends on CONFIG_ASH
+ help
+ Enable support for echo, built in to ash.
+
+# this entry also appears in coreutils/Config.in, next to the echo applet
+config CONFIG_FEATURE_FANCY_ECHO
+ bool " Enable echo options (-n and -e)"
+ default y
+ depends on CONFIG_ASH_BUILTIN_ECHO
+ help
+ This adds options (-n and -e) to echo.
+
config CONFIG_ASH_MAIL
bool " Check for new mail on interactive shells"
default y
diff --git a/shell/ash.c b/shell/ash.c
index 7f77594..9660890 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1249,6 +1249,9 @@ static int commandcmd(int, char **);
#endif
static int dotcmd(int, char **);
static int evalcmd(int, char **);
+#ifdef CONFIG_ASH_BUILTIN_ECHO
+static int echocmd(int, char **);
+#endif
static int execcmd(int, char **);
static int exitcmd(int, char **);
static int exportcmd(int, char **);
@@ -1308,39 +1311,12 @@ struct builtincmd {
/* unsigned flags; */
};
-#ifdef CONFIG_ASH_CMDCMD
-# ifdef JOBS
-# ifdef CONFIG_ASH_ALIAS
-# define COMMANDCMD (builtincmd + 7)
-# define EXECCMD (builtincmd + 10)
-# else
-# define COMMANDCMD (builtincmd + 6)
-# define EXECCMD (builtincmd + 9)
-# endif
-# else /* ! JOBS */
-# ifdef CONFIG_ASH_ALIAS
-# define COMMANDCMD (builtincmd + 6)
-# define EXECCMD (builtincmd + 9)
-# else
-# define COMMANDCMD (builtincmd + 5)
-# define EXECCMD (builtincmd + 8)
-# endif
-# endif /* JOBS */
-#else /* ! CONFIG_ASH_CMDCMD */
-# ifdef JOBS
-# ifdef CONFIG_ASH_ALIAS
-# define EXECCMD (builtincmd + 9)
-# else
-# define EXECCMD (builtincmd + 8)
-# endif
-# else /* ! JOBS */
-# ifdef CONFIG_ASH_ALIAS
-# define EXECCMD (builtincmd + 8)
-# else
-# define EXECCMD (builtincmd + 7)
-# endif
-# endif /* JOBS */
-#endif /* CONFIG_ASH_CMDCMD */
+
+#define COMMANDCMD (builtincmd + 5 + \
+ ENABLE_ASH_ALIAS + ENABLE_ASH_JOB_CONTROL)
+#define EXECCMD (builtincmd + 7 + \
+ ENABLE_ASH_CMDCMD + ENABLE_ASH_ALIAS + \
+ ENABLE_ASH_BUILTIN_ECHO + ENABLE_ASH_JOB_CONTROL)
#define BUILTIN_NOSPEC "0"
#define BUILTIN_SPECIAL "1"
@@ -1371,6 +1347,9 @@ static const struct builtincmd builtincmd[] = {
{ BUILTIN_REGULAR "command", commandcmd },
#endif
{ BUILTIN_SPEC_REG "continue", breakcmd },
+#ifdef CONFIG_ASH_BUILTIN_ECHO
+ { BUILTIN_REGULAR "echo", echocmd },
+#endif
{ BUILTIN_SPEC_REG "eval", evalcmd },
{ BUILTIN_SPEC_REG "exec", execcmd },
{ BUILTIN_SPEC_REG "exit", exitcmd },
@@ -8200,6 +8179,13 @@ exitcmd(int argc, char **argv)
/* NOTREACHED */
}
+#ifdef CONFIG_ASH_BUILTIN_ECHO
+static int
+echocmd(int argc, char **argv)
+{
+ return bb_echo(argc, argv);
+}
+#endif
/* $NetBSD: memalloc.c,v 1.27 2003/01/22 20:36:04 dsl Exp $ */
/*