diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2010-03-23 15:35:39 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-03-30 14:14:59 +0200 |
commit | a9ff0c8e8b720f1902a1e89444072e9469847a2f (patch) | |
tree | 13846f20a63329c3caac8bad408e6f59aebd06c5 /commands/echo.c | |
parent | adaffb5b0cbf75a86fd203bdb2264de2b3a29435 (diff) | |
download | barebox-a9ff0c8e8b720f1902a1e89444072e9469847a2f.tar.gz barebox-a9ff0c8e8b720f1902a1e89444072e9469847a2f.tar.xz |
echo: add -e option support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/echo.c')
-rw-r--r-- | commands/echo.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/commands/echo.c b/commands/echo.c index d5640a0f02..dfa14d67b9 100644 --- a/commands/echo.c +++ b/commands/echo.c @@ -25,6 +25,7 @@ #include <fs.h> #include <fcntl.h> #include <errno.h> +#include <libbb.h> static int do_echo(struct command *cmdtp, int argc, char *argv[]) { @@ -32,7 +33,10 @@ static int do_echo(struct command *cmdtp, int argc, char *argv[]) int fd = stdout, opt, newline = 1; char *file = NULL; int oflags = O_WRONLY | O_CREAT; - +#ifdef CONFIG_CMD_ECHO_E + char str[CONFIG_CBSIZE]; + int process_escape = 0; +#endif /* We can't use getopt() here because we want to * echo all things we don't understand. */ @@ -62,6 +66,11 @@ static int do_echo(struct command *cmdtp, int argc, char *argv[]) goto no_optarg_out; optind++; break; +#ifdef CONFIG_CMD_ECHO_E + case 'e': + process_escape = 1; + break; +#endif default: goto exit_parse; } @@ -80,7 +89,13 @@ exit_parse: for (i = optind; i < argc; i++) { if (i > optind) fputc(fd, ' '); - fputs(fd, argv[i]); +#ifdef CONFIG_CMD_ECHO_E + if (process_escape) { + process_escape_sequence(argv[i], str, CONFIG_CBSIZE); + fputs(fd, str); + } else +#endif + fputs(fd, argv[i]); } if (newline) |