Merge tag 'xilinx-for-v2025.01-rc3-v2' of https://source.denx.de/u-boot/custodians...
[u-boot.git] / cmd / echo.c
blob973213a03a66b57af5172e470a095b0e94f58e51
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 */
7 #include <command.h>
9 static int do_echo(struct cmd_tbl *cmdtp, int flag, int argc,
10 char *const argv[])
12 int i = 1;
13 bool space = false;
14 bool newline = true;
16 if (argc > 1) {
17 if (!strcmp(argv[1], "-n")) {
18 newline = false;
19 ++i;
23 for (; i < argc; ++i) {
24 if (space) {
25 putc(' ');
27 puts(argv[i]);
28 space = true;
31 if (newline)
32 putc('\n');
34 return 0;
37 U_BOOT_CMD(
38 echo, CONFIG_SYS_MAXARGS, 1, do_echo,
39 "echo args to console",
40 "[-n] [args..]\n"
41 " - echo args to console; -n suppresses newline"