diff --git a/ChangeLog b/ChangeLog index 9ba531c355945c804515700261bd4bc5314ca43e..ea14d3f0ecb55e3123247c646283bd74e2777504 100644 --- a/ChangeLog +++ b/ChangeLog @@ -394,19 +394,19 @@ 0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> - * Added mkfatfs, mkfifo, sleep, usleep and nice commands to NSH + * NSH: Added mkfatfs, mkfifo, sleep, usleep and nice commands * Fixed problem with console input in Cygwin-based simulator; NSH now works with simulator. * NSH will now execute commands in background * sched_get_priority_max/min returned error on SCHED_RR * Removed duplicate getenv() implementation in /lib * Correct detection of End-of-File in fgets - * Implement sh and crude script handler in NSH + * NSH: Implemented sh and crude script handler * Fix prototype of read() and write(). Need to use ssize_t and size_t, not int and unsigned int. - * Add support for redirection of command output in NSH + * NSH now supports redirection of command output * NSH can now use both telnet and serial front ends together - * $variable can be used for any command value in NSH. + * NSH: $variable can be used for any command value * Fixed an error in opendir() that could cause an assertion to fail inappropriately. * Correct an error in the FAT that caused files opened for writing with @@ -414,4 +414,5 @@ end of the file in that case. * NSH now supports last exit status $? * NSH now supports if-then[-else]-fi construct + * NSH now supports comments beginning with '#' diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index f84038533cfb8bff1934a4966429074dcbb9c1cc..fcf807ef7957fd8ab389d2bbc9a8363261bda617 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -1028,19 +1028,19 @@ buildroot-0.1.0 2007-03-09 <spudmonkey@racsa.co.cr> <pre><ul> nuttx-0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> - * Added mkfatfs, mkfifo, sleep, usleep and nice commands to NSH + * NSH: Added mkfatfs, mkfifo, sleep, usleep and nice commands * Fixed problem with console input in Cygwin-based simulator; NSH now works with simulator. * NSH will now execute commands in background * sched_get_priority_max/min returned error on SCHED_RR * Removed duplicate getenv() implementation in /lib * Correct detection of End-of-File in fgets - * Implement sh and crude script handler in NSH + * NSH: Implemented sh and crude script handler * Fix prototype of read() and write(). Need to use ssize_t and size_t, not int and unsigned int. - * Add support for redirection of command output in NSH + * NSH now supports redirection of command output * NSH can now use both telnet and serial front ends together - * $variable can be used for any command value in NSH. + * NSH: $variable can be used for any command value * Fixed an error in opendir() that could cause an assertion to fail inappropriately. * Correct an error in the FAT that caused files opened for writing with @@ -1048,6 +1048,7 @@ nuttx-0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> end of the file in that case. * NSH now supports last exit status $? * NSH now supports if-then[-else]-fi construct + * NSH now supports comments beginning with '#' pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/examples/nsh/nsh_main.c b/examples/nsh/nsh_main.c index bde02fc03d6a0c4365f93fd0f2b850345db1f0b5..b2915a75aeb1153941110e0e8510b1d3dd880f37 100644 --- a/examples/nsh/nsh_main.c +++ b/examples/nsh/nsh_main.c @@ -321,7 +321,7 @@ char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, char **saveptr) return NULL; } - /* Does the token begin with '>' */ + /* Does the token begin with '>' -- redirection of output? */ if (*pbegin == '>') { @@ -330,17 +330,29 @@ char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, char **saveptr) if (*(pbegin + 1) == '>') { *saveptr = pbegin + 2; - pbegin = (char*)g_redirect2; + pbegin = (char*)g_redirect2; } else { *saveptr = pbegin + 1; - pbegin = (char*)g_redirect1; + pbegin = (char*)g_redirect1; } } + + /* Does the token begin with '#' -- comment */ + + else if (*pbegin == '#') + { + /* Return NULL meaning that we are at the end of the line */ + + *saveptr = pbegin; + pbegin = NULL; + } else { - /* Does the token begin with '"'? */ + /* Otherwise, we are going to have to parse to find the end of + * the token. Does the token begin with '"'? + */ if (*pbegin == '"') { @@ -379,41 +391,41 @@ char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, char **saveptr) /* Save the pointer where we left off */ *saveptr = pend; - } - /* Check for references to environment variables */ + /* Check for references to environment variables */ - if (pbegin[0] == '$' && !quoted) - { - /* Check for built-in variables */ - - if (strcmp(pbegin, g_exitstatus) == 0) + if (pbegin[0] == '$' && !quoted) { - if (vtbl->np.np_fail) - { - return (char*)g_failure; - } - else + /* Check for built-in variables */ + + if (strcmp(pbegin, g_exitstatus) == 0) { - return (char*)g_success; + if (vtbl->np.np_fail) + { + return (char*)g_failure; + } + else + { + return (char*)g_success; + } } - } - /* Not a built-in? Return the value of the environment variable with this name */ + /* Not a built-in? Return the value of the environment variable with this name */ #ifndef CONFIG_DISABLE_ENVIRON - else - { - char *value = getenv(pbegin+1); - if (value) - { - return value; - } else { - return (char*)""; + char *value = getenv(pbegin+1); + if (value) + { + return value; + } + else + { + return (char*)""; + } } - } #endif + } } /* Return the beginning of the token. */