Special built-in command descriptions for the Korn shell or POSIX shell
Special commands are built into the Korn shell and POSIX shell and executed in the shell process.
The special built-in commands of the Korn shell are described below:
Item | Description |
---|---|
: [Argument ...] | Expands only arguments. It is used when a command is necessary, as in the then condition of an if command, but nothing is to be done by the command. |
. File [Argument ...] | Reads the complete specified file and then executes
the commands. The commands are executed in the current shell environment.
The search path specified by the PATH variable
is used to find the directory containing the specified file. If any
arguments are specified, they become the positional parameters. Otherwise,
the positional parameters are unchanged. The exit status is the exit
status of the most recent command executed. See Parameter substitution in the Korn shell or POSIX shell for more
information on positional parameters. Note: The .File [Argument ...]
command reads the entire file before any commands are carried out.
Therefore, the alias and unalias commands
in the file do not apply to any functions defined in the file.
|
break [n] | Exits from the enclosing for, while, until, or select loop, if one exists. If you specify the n parameter, the command breaks the number of levels specified by the n parameter. The value of n is any integer equal to or greater than 1. |
continue [n] | Resumes the next iteration of the enclosing for, while, until, or select loop. If you specify the n parameter, the command resumes at the nth enclosing loop. The value of n is any integer equal to or greater than 1. |
eval [Argument ...] | Reads the specified arguments as input to the shell and executes the resulting command or commands. |
exec [Argument ...] | Executes the command specified by the argument in place of this shell (without creating a new process). Input and output arguments can appear and affect the current process. If you do not specify an argument, the exec command modifies file descriptors as prescribed by the input and output redirection list. In this case, any file descriptor numbers greater than 2 that are opened with this mechanism are closed when invoking another program. |
exit [n] | Exits the shell with the exit status specified by the n parameter. The n parameter must be an unsigned decimal integer with range 0-255. If you omit the n parameter, the exit status is that of the most recent command executed. An end-of-file character also exits the shell unless the ignoreeof option of the set special command is turned on. |
export -p [Name[= Value]] ... | Marks the specified names for automatic export to
the environment of subsequently executed commands. -p writes
to standard output the names and values of all exported variables,
in the following format:
|
newgrp [Group] | Equivalent to the exec/usr/bin/newgrp [Group]
command. Note: This command does not return.
|
readonly -p [Name[= Value]] ... | Marks the names specified by the Name parameter
as read-only. These names cannot be changed by subsequent assignment.
-p writes to standard output the names and values of all
exported variables, in the following format:
|
return [n] | Causes a shell function to return to the invoking script. The return status is specified by the n parameter. If you omit the n parameter, the return status is that of the most recent command executed. If you invoke the return command outside of a function or a script, then it is the same as an exit command. |
set [+ |-abCefhkmnostuvx ] [+ |-o Option]... [+ |-AName] [Argument ...] | If no options or arguments are specified, the set command
writes the names and values of all shell variables in the collation
sequence of the current locale. When options are specified, they will
set or unset attributes of the shell, described as follows:
|
|
|
Preceding any of the set command
flags with a |
|
shift [n] | Renames the positional parameters, beginning with $ n +1 ...
through $1 .... The default value of the n parameter
is 1. The n parameter is any arithmetic
expression that evaluates to a nonnegative number less than or equal
to the $# parameter. |
times | Prints the accumulated user and system times for the shell and for processes run from the shell. |
trap [Command] [Signal] ... | Runs the specified command when the shell receives the specified signal or
signals. The Command parameter is read once when the trap is set and once when
the trap is taken. The Signal parameter can be given as a number or as the name
of the signal. Trap commands are executed in order of signal number. Any attempt to set a trap on a
signal that was ignored on entry to the current shell is ineffective. If the command is
- , all traps are reset to their original values. If you omit the command and the
first signal is a numeric signal number, then the ksh command resets the value of
the Signal parameter or parameters to the original values.Note: If you omit the
command and the first signal is a symbolic name, the signal is interpreted as a
command.
If the value of the Signal parameter is the ERR signal, the specified command is carried out whenever a command has a nonzero exit status. If the signal is DEBUG, then the specified command is carried out after each command. If the value of the Signal parameter is the 0 or EXIT signal and the trap command is executed inside the body of a function, the specified command is carried out after the function completes. If the Signal parameter is 0 or EXIT for a trap command set outside any function, the specified command is carried out on exit from the shell. Note: If a script receives a
SIGINT signal within a function, the EXIT signal cannot be trapped
when the shell exits.The trap command with no arguments prints a list of commands associated with each signal number. If the command specified is NULL, indicated as "" (empty quotes), then the ksh command will ignore the signal. For more information about how the Korn shell or the POSIX shell reads a character as a regular character, see Quotation of characters in the Korn shell or POSIX shell. For a complete list of Signal parameter values used in the trap command without the SIG prefix, see the sigaction, sigvec, or signal subroutine in the Technical Reference: Base Operating System and Extensions, Volume 2. |
typeset [+HLRZfilrtux [n]] [Name[=Value]] ... | Sets attributes and values for shell parameters.
When invoked inside a function, a new instance of the Name parameter
is created. The parameter value and type are restored when the function
completes. You can specify the following flags with the typeset command:
|
|
|
unset [-fv ] Name ... | Unsets the values and attributes of the parameters
given by the list of names. If -v is specified, Name refers
to a variable name, and the shell will unset it and remove it from
the environment. Read-only variables cannot be unset. Unsetting the ERRNO,
LINENO, MAILCHECK,
OPTARG, OPTIND,
RANDOM, SECONDS,
TMOUT, and underscore (_ )
variables removes their special meanings even if they are subsequently
assigned. If the -f flag is set, then Name refers to a function name, and the shell will unset the function definition. |