Merged in juniskane/apps_upstream/echo_fix_pr (pull request #135)

apps/nshlib: Fix echo command with zero arguments, broken after commit 8ecf618

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Juha Niskanen 2018-04-19 04:12:51 +00:00 committed by Gregory Nutt
parent c40cf98468
commit 052a7009b3

View File

@ -264,13 +264,13 @@ int cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
int i;
int s = 1;
if (0 == strncmp(argv[1], "-n", 2))
if (argc > 1 && 0 == strncmp(argv[1], "-n", 2))
{
s = 2;
}
/* echo each argument, separated by a space as it must have been on the
* command line
* command line.
*/
for (i = s; i < argc; i++)