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
This commit is contained 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
|
||||
|
52
shell/ash.c
52
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 $ */
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user