Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2000-2009 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 5 | */ |
| 6 | |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 7 | #include <command.h> |
| 8 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 9 | static int do_echo(struct cmd_tbl *cmdtp, int flag, int argc, |
| 10 | char *const argv[]) |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 11 | { |
Heinrich Schuchardt | a2f472d | 2021-01-20 12:13:30 +0100 | [diff] [blame] | 12 | int i = 1; |
| 13 | bool space = false; |
| 14 | bool newline = true; |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 15 | |
Heinrich Schuchardt | a2f472d | 2021-01-20 12:13:30 +0100 | [diff] [blame] | 16 | if (argc > 1) { |
| 17 | if (!strcmp(argv[1], "-n")) { |
| 18 | newline = false; |
| 19 | ++i; |
| 20 | } |
| 21 | } |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 22 | |
Heinrich Schuchardt | a2f472d | 2021-01-20 12:13:30 +0100 | [diff] [blame] | 23 | for (; i < argc; ++i) { |
| 24 | if (space) { |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 25 | putc(' '); |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 26 | } |
Heinrich Schuchardt | a2f472d | 2021-01-20 12:13:30 +0100 | [diff] [blame] | 27 | puts(argv[i]); |
| 28 | space = true; |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 29 | } |
| 30 | |
Heinrich Schuchardt | a2f472d | 2021-01-20 12:13:30 +0100 | [diff] [blame] | 31 | if (newline) |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 32 | putc('\n'); |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | U_BOOT_CMD( |
Heinrich Schuchardt | a2f472d | 2021-01-20 12:13:30 +0100 | [diff] [blame] | 38 | echo, CONFIG_SYS_MAXARGS, 1, do_echo, |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 39 | "echo args to console", |
Heinrich Schuchardt | a2f472d | 2021-01-20 12:13:30 +0100 | [diff] [blame] | 40 | "[-n] [args..]\n" |
| 41 | " - echo args to console; -n suppresses newline" |
Peter Tyser | eabe6d9 | 2009-10-16 17:36:25 -0500 | [diff] [blame] | 42 | ); |