NSH now supports comments

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@830 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-08-17 19:57:40 +00:00
parent 3d991a3d9f
commit ffaed10379
3 changed files with 52 additions and 38 deletions

View File

@ -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 '#'

View File

@ -1028,19 +1028,19 @@ buildroot-0.1.0 2007-03-09 &lt;spudmonkey@racsa.co.cr&gt
<pre><ul>
nuttx-0.3.13 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* 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 &lt;spudmonkey@racsa.co.cr&gt;
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 &lt;spudmonkey@racsa.co.cr&gt;

View File

@ -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
{
return (char*)g_success;
}
}
/* Check for built-in variables */
/* Not a built-in? Return the value of the environment variable with this name */
if (strcmp(pbegin, g_exitstatus) == 0)
{
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 */
#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. */