svn commit: trunk/busybox/shell
vda at busybox.net
vda at busybox.net
Fri Nov 23 21:20:22 UTC 2007
Author: vda
Date: 2007-11-23 13:20:21 -0800 (Fri, 23 Nov 2007)
New Revision: 20514
Log:
hush: implement echo builtin
builtin_echo - 36 +36
bltins 384 396 +12
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 48/0) Total: 48 bytes
Modified:
trunk/busybox/shell/Config.in
trunk/busybox/shell/hush.c
Changeset:
Modified: trunk/busybox/shell/Config.in
===================================================================
--- trunk/busybox/shell/Config.in 2007-11-23 21:08:38 UTC (rev 20513)
+++ trunk/busybox/shell/Config.in 2007-11-23 21:20:21 UTC (rev 20514)
@@ -166,6 +166,7 @@
select TRUE
select FALSE
select TEST
+ select ECHO
help
hush is a very small shell (just 18k) and it has fairly complete
Bourne shell grammar. It even handles all the normal flow control
Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c 2007-11-23 21:08:38 UTC (rev 20513)
+++ trunk/busybox/shell/hush.c 2007-11-23 21:20:21 UTC (rev 20514)
@@ -614,6 +614,7 @@
/* Function prototypes for builtins */
static int builtin_cd(char **argv);
+static int builtin_echo(char **argv);
static int builtin_eval(char **argv);
static int builtin_exec(char **argv);
static int builtin_exit(char **argv);
@@ -652,6 +653,8 @@
#endif
};
+/* For now, echo and test are unconditionally enabled.
+ * Maybe make it configurable? */
static const struct built_in_command bltins[] = {
BLTIN("[" , builtin_test, "Test condition"),
BLTIN("[[" , builtin_test, "Test condition"),
@@ -661,6 +664,7 @@
// BLTIN("break" , builtin_not_written, "Exit for, while or until loop"),
BLTIN("cd" , builtin_cd, "Change working directory"),
// BLTIN("continue", builtin_not_written, "Continue for, while or until loop"),
+ BLTIN("echo" , builtin_echo, "Write strings to stdout"),
BLTIN("eval" , builtin_eval, "Construct and run shell command"),
BLTIN("exec" , builtin_exec, "Exec command, replacing this shell with the exec'd process"),
BLTIN("exit" , builtin_exit, "Exit from shell"),
@@ -841,6 +845,17 @@
return test_main(argc, argv - argc);
}
+/* built-in 'test' handler */
+static int builtin_echo(char **argv)
+{
+ int argc = 0;
+ while (*argv) {
+ argc++;
+ argv++;
+ }
+ return bb_echo(argc, argv - argc);
+}
+
/* built-in 'eval' handler */
static int builtin_eval(char **argv)
{
More information about the busybox-cvs
mailing list