blob: fda844ee9d3524ebeac6d60769cbefa3c7649e52 [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
7#include <common.h>
8#include <command.h>
9
Simon Glass09140112020-05-10 11:40:03 -060010static int do_echo(struct cmd_tbl *cmdtp, int flag, int argc,
11 char *const argv[])
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050012{
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010013 int i = 1;
14 bool space = false;
15 bool newline = true;
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050016
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010017 if (argc > 1) {
18 if (!strcmp(argv[1], "-n")) {
19 newline = false;
20 ++i;
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050021 }
22 }
23
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010024 for (; i < argc; ++i) {
25 if (space) {
26 putc(' ');
27 }
28 puts(argv[i]);
29 space = true;
30 }
31
32 if (newline)
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050033 putc('\n');
34
35 return 0;
36}
37
38U_BOOT_CMD(
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010039 echo, CONFIG_SYS_MAXARGS, 1, do_echo,
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050040 "echo args to console",
Heinrich Schuchardtd0187342021-01-20 12:13:30 +010041 "[-n] [args..]\n"
42 " - echo args to console; -n suppresses newline"
Peter Tyser6b8f5ad2009-10-16 17:36:25 -050043);