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
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.
This is especially important on Windows systems if you use backslashes to separate path name components. For example, to create an alias for the cmd.exe print command that resides in c:\Windows\system32\print.exe, use one of the following two commands:
alias p="c:\\\\Windows\\\\system32\\\\print.exe" alias p='c:\\Windows\\system32\\print.exe'
Calling alias with name without any value assignment, displays name and its associated value with appropriate quoting.
causes the output generated by alias to be in a form that is suitable for use as input to the shell for setting aliases.
removes all tracked aliases.
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
each subsequent command you use in the shell automatically becomes a tracked alias. Invoking alias with the
-toption, 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
-xwithout any names, alias displays all exported aliases. Only exported aliases are passed to a shell that runs a shell script (that is, script.ksh).
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.
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 cmd.exe. For example:
alias ver="cmd.exe /c ver" alias rename="cmd.exe /c rename" alias copy="cmd.exe /c copy"
When this variable is set, the Enhanced UNIX Compatibility Mode is on and the virtual file system is in use.
All aliases are stored as typed. When the Enhanced UNIX Compatibility Mode is on, path names in aliases are interpreted as being path names in the virtual file system; otherwise, path names in aliases are interpreted as being path names in the regular file system.
For example, suppose you define:
alias echotext="/usr/bin/echo.exe text"
Typing echotext on the command line attempts to run the echo.exe command found in the /usr/bin directory. When the Enhanced UNIX Compatibility Mode is on, it looks for echo.exe in the /usr/bin directory of the virtual file system (that is, the $ROOTDIR/mksnt directory of the regualr file system). When that mode is off, it looks for echo.exe in the /usr/bin directory of the regular file system (which would be x:/usr/bin where x is the drive letter of the current drive). This directory is unlikely to exist and the alias would fail.
For details on the Enhanced UNIX Compatibility Mode and the virtual file system, see the EUCM reference page.
Possible exit status values are:
Failure because an alias could not be set.
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.
KornShell. POSIX.2. x/OPEN Portability Guide 4.0. Windows 2000. Windows XP. Windows Server 2003. Windows Vista. Windows 7. Windows Server 2008. Windows 8. Windows Server 2012.
On UNIX systems, alias is a built-in command of the KornShell, but not of the Bourne Shell.
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.
MKS Toolkit for Power Users
MKS Toolkit for System Administrators
MKS Toolkit for Developers
MKS Toolkit for Interoperability
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition
Using the MKS KornShell
MKS Toolkit 9.5 Documentation Build 3.