HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)
s
sh-posix(1) sh-posix(1)
additional aliases. If the last character of the alias value is a blank, the word following the alias is also
checked for alias substitution. Aliases can be used to redefine special commands, but cannot be used to
redefine the keywords listed in the "Compound Commands" subsection. Aliases can be created, listed, and
exported with the
alias command and can be removed with the
unalias command. Exported aliases
remain in effect for subshells but must be reinitialized for separate invocations of the shell (see the "Shell
Invocation" subsection).
Aliasing is performed when scripts are read, not while they are executed. Therefore, for it to take effect, an
alias must be executed before the command referring to the alias is read.
Aliases are frequently used as a shorthand for full path names. An option to the aliasing facility allows the
value of the alias to be automatically set to the full path name of the corresponding command. These
aliases are called tracked aliases. The value of a tracked alias is defined the first time the identifier is
read and becomes undefined each time the
PATH variable is reset. These aliases remain tracked so that
the next reference will redefine the value. Several tracked aliases are compiled into the shell. The
-h
option of the set command converts each command name that is an identifier into a tracked alias.
The following exported aliases are compiled into the shell but can be unset or redefined:
autoload=’typeset -fu’
command=’command ’
functions=’typeset -f’
history=’fc -l’
integer=’typeset -i’
local=typeset
nohup=’nohup ’
r=’fc -e -’
stop=’kill -STOP’
suspend=’kill -STOP $$’
type=’whence -v’
Tilde Substitution
After alias substitution is performed, each word is checked to see if it begins with an unquoted tilde (
˜). If
it does, the word up to a
/ is checked to see if it matches a user name in the
/etc/passwd file. If a
match is found, the
˜ and the matched login name are replaced by the login directory of the matched user.
If no match is found, the original text is left unchanged. A ˜ alone or before a
/ is replaced by the value of
the
HOME parameter. A ˜ followed by a + or - is replaced by the value of the parameter
PWD and
OLDPWD, respectively. In addition, tilde substitution is attempted when the value of a parameter assign-
ment begins with a ˜.
Command Substitution
The standard output from a command enclosed in parenthesis preceded by a dollar sign ($(
...)) or a pair of
grave accents (
‘...‘) can be used as part or all of a word; trailing newlines are removed. In the second
(archaic) form, the string between the accents is processed for special quoting characters before the com-
mand is executed. See the "Quoting" subsection. The command substitution
$(cat file) can be
replaced by the equivalent but faster
$(<file). Command substitution of most special commands that
do not perform input/output redirection are carried out without creating a separate process.
An arithmetic expression enclosed in double parenthesis preceded by a dollar sign ($((...))) is replaced by
the value of the arithmetic expression within the double parenthesis. See the "Arithmetic Evaluation" sub-
section for a description of arithmetic expressions.
Parameter Substitution
A parameter is an identifier, one or more decimal digits, or one of the characters !, #, $, *, -, ?, @, and
_.Anamed parameter (a parameter denoted by an identifier) has a value and zero or more attributes.
Named parameters can be assigned values and attributes with the typeset special command. Exported
parameters pass values and attributes to the environment.
The shell supports a limited one-dimensional array facility. An element of an array parameter is refer-
enced by a subscript. A subscript is denoted by a [, followed by an arithmetic expression, followed by a ].
See the "Arithmetic Evaluation" subsection. To assign values to an array, use set -A
name value ....
The value of all subscripts must be in the range of
0 through 1023. Arrays need not be declared. Any
reference to a named parameter with a valid subscript is legal and an array is created if necessary.
Referencing an array parameter without a subscript is equivalent to referencing the first element.
HP-UX 11i Version 1: September 2005 − 12 − Hewlett-Packard Company Section 1−−903