Specifications

72 Version 2.0
else, endif, and goto, the script will exit. If the error arousing script is a called by
another script, the caller script will continue to execute.
The lasterror shell variable allows scripts to test the results of the most recently
executed command using the if command. This variable is maintained by the shell,
is read-only, and cannot be modified by command set.
Script-only commands, as well as echo, which are used to control the logic of the
script, do not affect the value of variable lasterror. The lasterror environment
variable is not changed by comments.
4.3 Script Nesting
Scripts can be nested. A script can call one or more scripts. The embedded script will
be executed as a command. After the whole embedded script is executed completely,
the next command will be executed.
The UEFI Shell will automatically save and restore the running mode before and after
the execution of nested scripts so that the changes of running modes in nested scripts
will not affect the running mode of a parent script.
4.4 Output and Echoing
Output redirection is supported for scripts. Output redirection on a command in a
script file causes the output for that command to be redirected. Output redirection on
the invocation of a script causes the output for all commands executed from that
script to be redirected to the file, with the output of each command appended to the
end of the file. If a command in a script redirects its output to file1, while the output
is redirected to file2 on invocation of a whole script, the output of that command will
be redirected to file1, but the echo of the command itself (if echo state is on) will
appear in file2, as well as output of all other commands.
When a script is launched from the interactive shell, it inherits its echo state from
interactive shell or parent script. Changing echo state in the script does not affect the
echo state of the interactive shell. When a script calls another script, the called script
inherits the caller script’s current echo state. But if the called script changes the echo
state, after returning, the caller’s echo script changes, too.
4.5 Limitations
Following are some examples of known limitations with the UEFI scripts:
1. Cannot read and write the same file within a single command, for example,
fs0:>type test.nsh > test.nsh
2. goto cannot be used to jump into another loop.
3. Don’t use the same index variable in nested for statements.
4. Index values cannot be referred outside of the for statement that defines it.
Formatted: Bullets and Numbering