k

ksh(1)

ksh(1)

command in the replaced text, other than any that are in the process of being replaced, is tested for 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 rede®ne special built-in commands, but cannot be used to rede®ne the keywords listed above. 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 Invoking ksh below).

Aliasing is performed when scripts are read, not while they are executed. Therefore, for it to take effect, 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 de®ned the ®rst time the identi®er is read and becomes unde®ned each time the PATH variable is reset. These aliases remain tracked so that the next reference rede®nes the value. Several tracked aliases are compiled into the shell. The -hoption of the set command converts each command name that is an identi®er into a tracked alias.

The following exported aliases are compiled into the shell but can be unset or rede®ned:

autoload='typeset -fu' false='let 0' functions='typeset -f' hash='alias -t -' history='fc -l' integer='typeset -i' nohup='nohup '

r='fc -e -' stop='kill -STOP' suspend='kill -STOP $$' true=':' type='whence -v'

Tilde Substitution

After alias substitution is performed, each word is checked to see if it begins with an unquoted Ä. If it does, the word up to a / is checked to see if it matches a user name in the /etc/passwd ®le. If a match is found, the Ä and the matched login name are replaced by the login directory of the matched user. This is called a tilde substitution. 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 assignment begins with a Ä.

Command Substitution

The standard output from a command enclosed in parenthesis preceded by a dollar sign ( $(command) ) or a pair of back single quotes (accent grave) ( ÁcommandÁ ) can be used as part or all of a word; trailing new-lines are removed. In the second (archaic) form, the string between the quotes is processed for special quoting characters before the command is executed (see Quoting below). The command substitution $(cat file) can be replaced by the equivalent but faster $(<file). Command substitution of most special commands (built-ins) that do not perform I/O redirection are carried out without creating a separate process. However, command substitution of a function creates a separate process to execute the function and all commands (built-in or otherwise) in that function.

An arithmetic expression enclosed in double parenthesis preceded by a dollar sign ($((expression))) is replaced by the value of the arithmetic expression within the double parenthesis (see Arithmetic Evaluation below for a description of arithmetic expressions).

Parameter Substitution

A parameter is an identi®er, one or more digits, or any of the characters *, @, #, ?, -, $, and !. A named parameter (a parameter denoted by an identi®er) has a value and zero or more attributes. Named parameters can be assigned values and attributes by using the typeset special command. Attributes supported by ksh are described later 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 referenced by a subscript. A subscript is denoted by a [ followed by an arithmetic expression (see Arithmetic Evaluation below) followed by a ]. To assign values to an array, use set -Aname value ... . The value

Section 1398

− 3 −

HP-UX Release 11i: December 2000