alias

display or create command aliases

KornShell Built-in


SYNOPSIS

alias [-tx] [name[=value] ...]

alias -r


DESCRIPTION

When the first word of a KornShell command line is not a shell keyword, the shell checks for the word in the list of currently defined aliases. If it finds a match, the shell replaces the alias with its associated string value. The result is a new command line that might begin with a shell function name, a built-in command, an external command or another alias.

When the shell performs alias substitution, it checks to see if value ends with a blank. If so, the shell also checks the next word of the command line for aliases. The shell then checks the new command line for aliases and expands them, following these same rules. This process continues until there are no aliases left on the command line or recursion occurs in the expansion of aliases.

Calling alias without parameters displays all the currently defined aliases and their associated values. Values appear with appropriate quoting so that they are suitable for re-input to the shell.

Calling alias with parameters in the form of
name=value
creates an alias for each name with the given string value.

If you are defining an alias where value contains a backslash character, you must precede it with another backslash since when the shell performs the expansion, it interprets a backslash as the escape character. If you use double quotes to enclose value, you must precede each component of a double backslash with an additional backslash since the shell escapes characters both when assigning the alias and again when expanding it.

To avoid using four backslashes to represent a single backslash, use apostrophes rather than double quotes to enclose value, since the shell does not escape characters enclosed in apostrophes during assignment. As a result, the shell only escapes characters within apostrophes when expanding the alias.

Calling alias with name without any value assignment, displays name and its associated value with appropriate quoting.

Options

-r

removes all tracked aliases.

-t

makes each name on the command line a tracked alias. Each tracked alias resolves to its full path name; thus the shell avoids searching the PATH directories whenever you invoke the command. The shell assigns the full path name of a tracked alias the first time that you invoke it. It reassigns a path name the first time you use the alias after changing the variable PATH. When you issue the command

set -h
each subsequent command you use in the shell automatically becomes a tracked alias. Invoking alias with the -t option, but without any specified names, displays all currently defined tracked aliases with appropriate quoting.

-x

marks each alias name on the command line for export. If you specify -x without any names, alias displays all exported aliases. Only exported aliases are passed to a shell that runs a shell script (that is, script.ksh).

Built-in Aliases

There are several aliases built into the shell:
alias functions="typeset -f"
alias hash="alias -t"
alias history="fc -l"
alias integer="typeset -i"
alias nohup="nohup "
alias r="fc -s"
On systems supporting job control:
alias stop="kill -STOP"
alias suspend="stop \$\$"
You can change or remove any of these aliases. See the relevant manual pages for details.


EXAMPLES

The command:
alias ls="ls -C"
defines ls as an alias. From this point onward, when you issue an ls command, it produces multi-column output by default. The alias command provides a simple way to access other functions built into the shell.

alias ver="command.com /c ver"
alias rename="command.com /c rename"
alias copy="command.com /c copy"


DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

1

Failure because an alias could not be set.

2

Failure because of an invalid command line option.

If you define alias to determine the values of a set of names, the exit status is the number of those names that are not currently defined as aliases.


PORTABILITY

KornShell. POSIX.2. x/OPEN Portability Guide 4.0.

On UNIX systems, alias is a built-in command of the KornShell, but not of the Bourne Shell.

The -t and -x options are extensions to the POSIX standard.


NOTE

This command is built into the MKS KornShell.

Since exported aliases are only available in the current shell environment and to the child processes of this environment, they are unavailable to any new shell environments that are started. To make an alias available to all shell environments, define it as a non-exported alias in the MKS KornShell ENV file, which is executed whenever a new shell is run.


SEE ALSO

Commands:
fc, functions, hash, history, integer, r, set, sh, typeset, unalias


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]