]>
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 | ||
09140113 SG |
10 | static int do_echo(struct cmd_tbl *cmdtp, int flag, int argc, |
11 | char *const argv[]) | |
6b8f5ad1 | 12 | { |
d018734c HS |
13 | int i = 1; |
14 | bool space = false; | |
15 | bool newline = true; | |
16 | ||
17 | if (argc > 1) { | |
18 | if (!strcmp(argv[1], "-n")) { | |
19 | newline = false; | |
20 | ++i; | |
21 | } | |
22 | } | |
6b8f5ad1 | 23 | |
d018734c HS |
24 | for (; i < argc; ++i) { |
25 | if (space) { | |
6b8f5ad1 | 26 | putc(' '); |
6b8f5ad1 | 27 | } |
d018734c HS |
28 | puts(argv[i]); |
29 | space = true; | |
6b8f5ad1 PT |
30 | } |
31 | ||
d018734c | 32 | if (newline) |
6b8f5ad1 PT |
33 | putc('\n'); |
34 | ||
35 | return 0; | |
36 | } | |
37 | ||
38 | U_BOOT_CMD( | |
d018734c | 39 | echo, CONFIG_SYS_MAXARGS, 1, do_echo, |
6b8f5ad1 | 40 | "echo args to console", |
d018734c HS |
41 | "[-n] [args..]\n" |
42 | " - echo args to console; -n suppresses newline" | |
6b8f5ad1 | 43 | ); |