From a90e031028dece53bcb37705cce2c14107718c77 Mon Sep 17 00:00:00 2001
From: Gregory Nutt Last Updated: October 1, 2018 Last Updated: October 2, 2018
+ A group-wide environment variable is created with the same value as the local NSH variable; the local NSH variable is removed.
+
@@ -2980,52 +2987,61 @@ foovalue
nsh>
- If
@@ -1766,6 +1766,13 @@ nsh> env
PATH=/bin
foo=bar
+
NuttShell (NSH)
-
+ NOTE: This behavior differs from the Bash shell.
+ Bash would retain the local Bash variable which will shadow the environment variable of the same name.
+
CONFIG_NSH_VARS
is set, the effect of this set
command is to set the local NSH variable. Otherwise, the group-wide environment variable will be set.
+ If CONFIG_NSH_VARS
is selected, the effect of this set
command is to set the local NSH variable. Otherwise, the group-wide environment variable will be set.
+export
, then the set
command will set the value of the environment variable rather than the local NSH variable.
- Set the 'exit on error control' and/or 'print a trace' of commands when parsing - scripts in NSH. The settings are in effect from the point of execution, until - they are changed again, or in the case of the init script, the settings are - returned to the default settings when it exits. Included child scripts will run - with the parents settings and changes made in the child script will effect the - parent on return. +
+ 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. +
- Use 'set -e' to enable and 'set +e' to disable (ignore) the exit condition on commands. - The default is -e. Errors cause script to exit. + Set the exit on error control and/or print a trace of commands when parsing scripts in NSH. + The settings are in effect from the point of execution, until they are changed again, or in the case of the initialization script, the settings are returned to the default settings when it exits. + Included child scripts will run with the parents settings and changes made in the child script will effect the parent on return.
+
+ Use set -e
to enable and set +e
to disable (ignore) the exit condition on commands.
+ The default is -e. Errors cause script to exit.
+
+ Use set -x
to enable and set +x
to disable (silence) printing a trace of the script commands as they are executed.
+ The default is +x
: no printing of a trace of script commands as they are executed.
+
- Use 'set -x' to enable and 'set +x' to disable (silence) printing a trace of the script - commands as they are executed. - The default is +x: no printing of a trace of script commands as they are executed. -
- Example 1 - no exit on command not found +- set +e - notacommand +set +e +notacommand- +
Example 2 - will exit on command not found +
- set -e - notacommand +set -e +notacommand- +
Example 3 - will exit on command not found, and print a trace of the script commands +
- set -ex +set -ex- - Example 4 - will exit on command not found, and print a trace of the script commands - and set foobar to foovalue. +
+ Example 4 - will exit on command not found, and print a trace of the script commands and set foobar to foovalue. +
- set -ex foobar foovalue - nsh> echo $foobar - foovalue +set -ex foobar foovalue +nsh> echo $foobar +foovalue-