blob: 973213a03a66b57af5172e470a095b0e94f58e51 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peter Tyser6b8f5ad2009-10-16 17:36:25 -05002/*
3 * Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Peter Tyser6b8f5ad2009-10-16 17:36:25 -05005 */
6
Peter Tyser6b8f5ad2009-10-16 17:36:25 -05007#include <command.h>
8
Simon Glass09140112020-05-10 11:40:03 -06009static int do_echo(struct cmd_tbl *cmdtp, int flag, int argc,
10 char *const argv[])
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050011{
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010012 int i = 1;
13 bool space = false;
14 bool newline = true;
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050015
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010016 if (argc > 1) {
17 if (!strcmp(argv[1], "-n")) {
18 newline = false;
19 ++i;
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050020 }
21 }
22
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010023 for (; i < argc; ++i) {
24 if (space) {
25 putc(' ');
26 }
27 puts(argv[i]);
28 space = true;
29 }
30
31 if (newline)
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050032 putc('\n');
33
34 return 0;
35}
36
37U_BOOT_CMD(
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010038 echo, CONFIG_SYS_MAXARGS, 1, do_echo,
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050039 "echo args to console",
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010040 "[-n] [args..]\n"
41 " - echo args to console; -n suppresses newline"
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050042);