execexecute a command in place of the current shell |
KornShell Built-in |
exec [command_line]
exec is a command_line for another
command. exec runs this command without creating a new
process. Some people picture this as overlaying the command on top of the
currently executing KornShell. When the command exits, control returns to the
parent of the shell.
Input and output redirections are valid in the command_line.
You can modify the input and output descriptors of the shell
by giving only input and output redirections in the command. For example,
redirects the standard error stream toexec 2>errors
errors in all
subsequent commands run by the shell.
If you do not specify a command_line, exec simply
returns a successful exit status.
overlays the MKS KornShell with a copy ofexec 'c:\dos\command.com'
command.com.
exec does not return to
the shell. Instead, the KornShell exits with the exit status of
command_line or one of the following exit status values:
1-125A redirection error occurred.
126The command in command_line was found but it was not an executable utility.
127The given command_line could not be executed because the command
could not be found in the current PATH.
exec returns
with an exit value of zero.
sh