nsh/echo: Fix echo previous behavior, single write with '\n'

This commit fixes the previous behavior where an echo with a
single string and its default new line is send as single write().

This issue came from:  https://github.com/apache/nuttx-apps/pull/1559

Signed-off-by: Alan C. Assis <acassis@gmail.com>
This commit is contained in:
Alan Carvalho de Assis 2026-06-26 12:41:02 -03:00 committed by Michal Lenc
parent fee2ddbf54
commit ae718ba47f

View file

@ -390,19 +390,18 @@ do_echo:
str_escape(argv[0]);
}
nsh_output(vtbl, "%s", argv[0]);
if (argc > 1)
{
nsh_output(vtbl, "%s ", argv[0]);
}
else
{
nsh_output(vtbl, newline ? "%s\n" : "%s", argv[0]);
break;
}
--argc;
++argv;
if (argc > 0)
{
nsh_output(vtbl, " ");
}
}
if (newline)
{
nsh_output(vtbl, "\n");
}
return OK;