User`s guide
5-11
Tips and Features for Administrators
Quoting
Quotation marks in the EFI Shell are used for argument grouping. A quoted string is treated
as a single argument to a command, and any whitespace characters included in the quoted
string are just part of that single argument.
Quoting an environment variable does not have any effect on the de-referencing of that
variable. Double quotation marks “” are used to denote strings. Single quotation marks are
not treated specially by the Shell in any way. Empty strings are treated as valid command
line arguments.
Executing Batch Scripts
The EFI Shell has the capability of executing commands from a file (batch script). EFI Shell
batch script files are named using the .nsh extension. Batch script files can be either
UNICODE or ASCII format files. EFI Shell script files are invoked by entering the filename at
the command prompt, with or without the filename extension.
Up to nine (9) positional arguments are supported for batch scripts. Positional argument
substitution is performed before the execution of each line in the script file. Positional
arguments are denoted by %n, where n is a digit between 0 and 9. By convention, %0 is the
name of the script file currently being executed. In batch scripts, argument substitution is
performed first, then variable substitution. Thus, for a variable containing %2, the variable
will be replaced with the literal string %2, not the second argument on the command line. If
no real argument is found to substitute for a positional argument, then the positional
argument is ignored. Script file execution can be nested; that is, script files may be executed
from within other script files. Recursion is allowed.
Output redirection is fully supported. 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 batch
script causes the output for all commands executed from that batch script to be redirected to
the file, with the output of each command appended to the end of the file.
By default, both the input and output for all commands executed from a batch script are
echoed to the console. Display of commands read from a batch file can be suppressed via
the echo –off command (see echo). If output for a command is redirected to a file, then
that output is not displayed on the console. Note that commands executed from a batch
script are not saved by the Shell for DOSkey history (up-arrow command recall).
Error Handling in Batch Scripts
By default, if an error is encountered during the execution of a command in a batch script,
the script will continue to execute.
The lasterror Shell variable allows batch scripts to test the results of the most recently
executed command using the if command. This variable is not an environment variable, but
is a special variable maintained by the Shell for the lifetime of that instance of the Shell.
Comments in Script Files
Comments can be embedded in batch scripts. The # character on a line is used to denote
that all characters on the same line and to the right of the # are to be ignored by the Shell.
Comments are not echoed to the console.
EFI Shell Commands
Most Shell commands can be invoked from the EFI Shell prompt. However there are several
commands that are only available for use from within batch script files.
Note:
The "Batch-only" column indicates if the command is only available from within script files.
The following sections provide more details on each of the individual commands.
Command help command_name displays the details of the command_name .