]>
Commit | Line | Data |
---|---|---|
6b8f5ad1 PT |
1 | /* |
2 | * Copyright 2000-2009 | |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
6b8f5ad1 PT |
6 | */ |
7 | ||
8 | #include <common.h> | |
9 | #include <command.h> | |
10 | ||
088f1b19 | 11 | static int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
6b8f5ad1 PT |
12 | { |
13 | int i; | |
14 | int putnl = 1; | |
15 | ||
16 | for (i = 1; i < argc; i++) { | |
bb64d1c9 JH |
17 | char *p = argv[i]; |
18 | char *nls; /* new-line suppression */ | |
6b8f5ad1 PT |
19 | |
20 | if (i > 1) | |
21 | putc(' '); | |
bb64d1c9 JH |
22 | |
23 | nls = strstr(p, "\\c"); | |
24 | if (nls) { | |
25 | char *prenls = p; | |
26 | ||
27 | putnl = 0; | |
28 | /* | |
29 | * be paranoid and guess that someone might | |
30 | * say \c more than once | |
31 | */ | |
32 | while (nls) { | |
33 | *nls = '\0'; | |
34 | puts(prenls); | |
35 | *nls = '\\'; | |
36 | prenls = nls + 2; | |
37 | nls = strstr(prenls, "\\c"); | |
6b8f5ad1 | 38 | } |
bb64d1c9 JH |
39 | puts(prenls); |
40 | } else { | |
41 | puts(p); | |
6b8f5ad1 PT |
42 | } |
43 | } | |
44 | ||
45 | if (putnl) | |
46 | putc('\n'); | |
47 | ||
48 | return 0; | |
49 | } | |
50 | ||
51 | U_BOOT_CMD( | |
52 | echo, CONFIG_SYS_MAXARGS, 1, do_echo, | |
53 | "echo args to console", | |
54 | "[args..]\n" | |
55 | " - echo args to console; \\c suppresses newline" | |
56 | ); |