Parameters
A parameter is used to store data. You can access the value of a
parameter by preceding its name with a dollar sign
($) and surrounding the name with brackets
({ }). The brackets are optional when the name is
a single digit, is a special parameter, or is a single identifier.
See "Parameter expansion" for more
information about expanding the value of a parameter.
Positional parameters
A positional parameter is a decimal number starting from one.
Initially, qsh sets the positional parameters to
the command line arguments that follow the name of the shell
script. The positional parameters are temporarily replaced when a
shell function is called and can be reassigned using the set and shift utilities.
Special parameters
A special parameter is denoted by one of these special
characters:
- * (Positional parameters)
- (Asterisk) Expands to the positional parameters, starting from
one. When the expansion occurs within a string with quotation marks, it
expands to a single field with the value of each parameter
separated by the first character of the IFS
variable, or by a <space> if IFS is
unset.
- @ (Positional parameters)
- (At sign) Expands to the positional parameters, starting from
one. When the expansion occurs within quotation marks, each
positional parameter expands as a separate argument. If there are
no positional parameters, the expansion of @
generates zero arguments, even when @ is
in quotation marks.
- # (Number of positional parameters)
- (Number sign) Expands to the decimal number of positional
parameters. It is initially set to the number of arguments when
qsh is invoked. It can be changed by the set, shift, or dot utilities or by calling a function.
- ? (Exit status)
- (Question mark) Expands to the decimal exit status of the most
recent command. A value of zero indicates successful completion. A
non-zero value indicates an error. A command ended by a signal
number has an exit status of 128 plus the signal number.
- - (Option flags)
- (Minus) Expands to the current option flags (the single-letter
option names concatenated into a string) as specified when
qsh is invoked, by set, or
implicitly by qsh.
- $ (Process ID of current shell)
- (Dollar sign) Expands to the decimal process ID of the current
shell. A subshell retains the same value of $ as
the current shell even if the subshell is running in a different
process.
- ! (Background process ID)
- (Exclamation mark) Expands to the decimal process ID of the
most recent background command run from the current shell. For a
pipeline, the process ID is that of the last command in the
pipeline.
- 0 (Name of shell script)
- (Zero) Expands to the name of the shell or shell script.