diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index a505b1faa..0256fe2ac 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -158,8 +158,8 @@ static const struct cmdmap_s g_cmdmap[] = #endif #ifndef CONFIG_NSH_DISABLE_CAT - CMD_MAP("cat", cmd_cat, 2, CONFIG_NSH_MAXARGUMENTS, - " [ [ ...]]"), + CMD_MAP("cat", cmd_cat, 1, CONFIG_NSH_MAXARGUMENTS, + "[ [ [ ...]]]"), #endif #ifndef CONFIG_DISABLE_ENVIRON diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index ca07ba952..31687acd2 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -791,6 +791,25 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) } } + if (argc == 1) + { + char *buf = malloc(BUFSIZ); + + /* Dump from input */ + + while (true) + { + ssize_t n = nsh_read(vtbl, buf, BUFSIZ); + + if (n == 0) + break; + + nsh_write(vtbl, buf, n); + } + + free(buf); + } + return ret; } #endif