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