Update a README/Improve some C comments.
This commit is contained in:
parent
65e0b791b7
commit
8b01ea4434
@ -520,25 +520,32 @@ o export <name> [<value>]
|
|||||||
|
|
||||||
1. Using 'export' to promote an NSH variable to an environment variable.
|
1. Using 'export' to promote an NSH variable to an environment variable.
|
||||||
|
|
||||||
nsh> env
|
nsh> env
|
||||||
PATH=/bin
|
PATH=/bin
|
||||||
|
|
||||||
nsh> set foo bar
|
nsh> set foo bar
|
||||||
nsh> env
|
nsh> env
|
||||||
PATH=/bin
|
PATH=/bin
|
||||||
|
|
||||||
nsh> export foo
|
nsh> export foo
|
||||||
nsh> env
|
nsh> env
|
||||||
PATH=/bin
|
PATH=/bin
|
||||||
foo=bar
|
foo=bar
|
||||||
|
|
||||||
|
A group-wide environment variable is created with the same value as the
|
||||||
|
local NSH variable; the local NSH variable is removed.
|
||||||
|
|
||||||
|
NOTE: This behavior differs from the Bash shell. Bash will retain the
|
||||||
|
local Bash variable which will shadow the environment variable of the
|
||||||
|
same name.
|
||||||
|
|
||||||
2. Using 'export' to set an environment variable
|
2. Using 'export' to set an environment variable
|
||||||
|
|
||||||
nsh> export dog poop
|
nsh> export dog poop
|
||||||
nsh> env
|
nsh> env
|
||||||
PATH=/bin
|
PATH=/bin
|
||||||
foo=bar
|
foo=bar
|
||||||
dog=poop
|
dog=poop
|
||||||
|
|
||||||
The export command is not supported by NSH unless both CONFIG_NSH_VARS=y
|
The export command is not supported by NSH unless both CONFIG_NSH_VARS=y
|
||||||
and CONFIG_DISABLE_ENVIRON is not set.
|
and CONFIG_DISABLE_ENVIRON is not set.
|
||||||
@ -1116,8 +1123,18 @@ o set [{+|-}{e|x|xe|ex}] [<name> <value>]
|
|||||||
foovalue
|
foovalue
|
||||||
nsh>
|
nsh>
|
||||||
|
|
||||||
If CONFIG_NSH_VARS is set, the effect of this 'set' command is to set the local
|
If CONFIG_NSH_VARS is selected, the effect of this 'set' command is to set
|
||||||
NSH variable. Otherwise, the group-wide environment variable will be set.
|
the local NSH variable. Otherwise, the group-wide environment variable
|
||||||
|
will be set.
|
||||||
|
|
||||||
|
If the local NSH variable has already been 'promoted' to an environment
|
||||||
|
variable, then the 'set' command will set the value of the environment
|
||||||
|
variable rather than the local NSH variable.
|
||||||
|
|
||||||
|
NOTE: The Bash shell does not work this way. Bash would set the value of
|
||||||
|
the local Bash variable and would not modify the environment variable.
|
||||||
|
The local Bash variable would that then shadow the environment variable
|
||||||
|
with a differing value.
|
||||||
|
|
||||||
Set the 'exit on error control' and/or 'print a trace' of commands when parsing
|
Set the 'exit on error control' and/or 'print a trace' of commands when parsing
|
||||||
scripts in NSH. The settinngs are in effect from the point of exection, until
|
scripts in NSH. The settinngs are in effect from the point of exection, until
|
||||||
|
@ -411,6 +411,9 @@ int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
#ifndef CONFIG_DISABLE_ENVIRON
|
#ifndef CONFIG_DISABLE_ENVIRON
|
||||||
/* Check if the NSH variable has already been promoted to an group-
|
/* Check if the NSH variable has already been promoted to an group-
|
||||||
* wide environment variable.
|
* wide environment variable.
|
||||||
|
*
|
||||||
|
* REVISIT: Is this the correct behavior? Bash would create/modify
|
||||||
|
* a local variable that shadows the environment variable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
oldvalue = getenv(argv[ndx]);
|
oldvalue = getenv(argv[ndx]);
|
||||||
@ -529,7 +532,11 @@ int cmd_export(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Unset NSH variable */
|
/* Unset NSH variable.
|
||||||
|
*
|
||||||
|
* REVISIT: Is this the correct behavior? Bash would retain
|
||||||
|
* a local variable that shadows the environment variable.
|
||||||
|
*/
|
||||||
|
|
||||||
status = nsh_unsetvar(vtbl, argv[1]);
|
status = nsh_unsetvar(vtbl, argv[1]);
|
||||||
if (status < 0 && status != -ENOENT)
|
if (status < 0 && status != -ENOENT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user