Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)
User Commands (s) sh(1)
{}
[[ ]]
Command Aliasing
The first word of each command is replaced by the text of an alias (if an alias for this word was
defined). The first character of an alias name can be any nonspecial printable character, but the
rest of the characters must be the same as for a valid identifier. The replacement string can con-
tain any valid shell script, including the metacharacters previously listed. The
first word of each
command in the replaced text, other than any that are in the process of being replaced, will be
tested for aliases. If the last character of the alias value is a space, the word following the alias
will also be checked for alias substitution.
Aliases can be used to redefine special built-in commands but cannot be used to redefine the
reserved words previously listed. Aliases can be created, listed, and exported with the alias com-
mand and can be removed with the unalias command. Exported aliases remain in effect for
scripts invoked by name, but must be reinitialized for separate invocations of the shell. (See
Invocation.)
Aliasing is performed when scripts are read, not while they are executed. Therefore, for an alias
to take effect, the alias definition command has to be executed before the command that refer-
ences the alias is read.
Aliases are frequently used as shorthand for full pathnames. An option to the aliasing facility
allows the value of the alias to be automatically set to the full pathname of the corresponding
command. These aliases are called tracked aliases.
The value of a tracked alias is defined the first time the corresponding command is looked up and
becomes undefined each time the PATH environment variable is reset. These aliases remain
tracked so that the next subsequent reference will redefine the value. Several tracked aliases are
compiled into the shell. The -h flag of the set command makes each referenced command name
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’
hash=’alias -t -’
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, then the word up to a / (slash) is checked to see if it matches a username in the
/etc/passwd file. If a match is found, the tilde and the matched name are replaced by the login
directory of the matched user. This is called a tilde substitution. If no match is found, the origi-
nal text is left unchanged. A tilde by itself, or in front of a /, is replaced by the value of the
HOME parameter. A tilde followed by a + (plus sign) or - (dash) is replaced by $PWD and
$OLDPWD, respectively.
527188-004 Hewlett-Packard Company 8−17