From 35f8395a0b218f6c215e4b5b3e501980e78a65e1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 27 Feb 2014 11:13:21 -0600 Subject: [PATCH] NSH cat command now adds to newline at the end of the file so that the NSH prompt is always on a newline --- ChangeLog.txt | 8 +++++++- nshlib/nsh_fscmds.c | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 29bab006a..20397b61d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -844,4 +844,10 @@ settings (2014-2-20). * nshlib/nsh_telnetd.c: Use strncpy vs strcpy to avoid overrun the username and password buffers. From Bertold Van den Bergh (2014-2-22). - + * nshlib/Kconfig, nsh_proccmds.c: If the CPU load feature and the procfs + features are enabled, then show CPU load used by each thread in the + 'ps' command (2014-2-27). + * nshlib/nsh_fscmds.c: Add a newline after printing the file in the + 'cat' command. This prevents the NSH prompt from be in the same line + as the final line of the file in the case where there is no newline + at the end of the file (2014-2-27). diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index 778d2d584..9202badef 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -502,6 +502,17 @@ static int cat_common(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, } } + /* Make sure that the following NSH prompt appears on a new line. If the + * file ends in a newline, then this will print an extra blank line + * before the prompt, but that is preferable to the case where there is + * no newline and the NSH prompt appears on the same line as the cat'ed + * file. + */ + + nsh_output(vtbl, "\n"); + + /* Close the input file and return the result */ + (void)close(fd); return ret; }