]>
Commit | Line | Data |
---|---|---|
d684c216 L |
1 | /* |
2 | * Copyright 2000-2009 | |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
4 | * | |
5 | * SPDX-License-Identifier: GPL-2.0+ | |
6 | */ | |
7 | ||
8 | #include "common.h" | |
9 | #include "command.h" | |
10 | ||
11 | ||
d0581f88 | 12 | command_ret_t do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
d684c216 L |
13 | { |
14 | uint_fast8_t putnl = 1; | |
15 | ||
16 | (void) cmdtp; (void) flag; | |
17 | ||
18 | for (uint_fast8_t i = 1; i < argc; i++) { | |
19 | ||
20 | uint_fast8_t backslash = 0; | |
21 | char *p = argv[i]; | |
22 | char c; | |
23 | ||
24 | if (i != 1) | |
25 | putchar(' '); | |
26 | while ((c = *p++) != '\0') { | |
27 | ||
28 | if(backslash) { | |
29 | backslash = 0; | |
30 | if (c == 'c') { | |
31 | putnl = 0; | |
32 | continue; | |
33 | } else | |
34 | putchar('\\'); | |
35 | } else { | |
36 | if (c == '\\') { | |
37 | backslash = 1; | |
38 | continue; | |
39 | } | |
40 | } | |
41 | putchar(c); | |
42 | } | |
43 | } | |
44 | ||
45 | if (putnl) | |
46 | putchar('\n'); | |
47 | ||
d0581f88 | 48 | return CMD_RET_SUCCESS; |
d684c216 L |
49 | } |
50 | ||
51 | #if 0 | |
52 | U_BOOT_CMD( | |
53 | echo, CONFIG_SYS_MAXARGS, 1, do_echo, | |
54 | "echo args to console", | |
55 | "[args..]\n" | |
56 | " - echo args to console; \\c suppresses newline" | |
57 | ); | |
58 | #endif |