Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)

User Commands (s) sh(1)
${parameter:-word}
Substitutes the value of parameter if it is set and non-null; otherwise, substitutes word.
${parameter:=word}
Sets parameter to word if it is not set or is null; the value of the parameter is then sub-
stituted. Positional parameters cannot be assigned values in this way.
${parameter:?word}
Substitutes the value of parameter if it is set and is non-null; otherwise, print word and
exit from the shell. If word is omitted, a standard message is printed.
${parameter:+word}
Substitutes word if parameter is set and is non-null; otherwise, substitutes nothing.
${parameter#pattern} | ${parameter##pattern}
Causes the value of this substitution to be the value of parameter with the matched
portion deleted if the shell pattern matches the beginning of the value of parameter;
otherwise the value of parameter is substituted. In the rst form, the smallest matching
pattern is deleted and in the second form, the largest matching pattern is deleted.
${parameter%pattern} | ${parameter%%pattern}
Causes the value of this substitution to be the value of parameter with the matched part
deleted if the shell pattern matches the end of the value of parameter; otherwise, sub-
stitute the value of parameter. In the rst form, the smallest matching pattern is
deleted and in the second form, the largest matching pattern is deleted.
If the : (colon) is omitted from the previous expressions, then the shell checks only whether
parameter is set or not.
In the previous expressions, word is not evaluated unless it is to be used as the substituted string,
so that, in the following example, pwd is executed only if d is not set or is null:
echo ${d:-$(pwd)}
The following parameters are automatically set by the shell:
# (hash mark)
The number of positional parameters in decimal.
- (dash)
Flags supplied to the shell on invocation or by the set command.
? (question mark)
The decimal value returned by the last executed command.
$ (dollar sign)
The process number of this shell.
_ (underscore)
Initially, an absolute pathname of the shell or script being executed as passed in the
environment. Subsequently, the value is assigned the last argument of the previous com-
mand. This parameter is not set for commands that are asynchronous.
! (exclamation point)
The process number of the last background command invoked.
ERRNO The value of errno as set by the most recently failed system call. This value is system
dependent and is intended for debugging purposes.
527188-003 Hewlett-Packard Company 819