Bash exec

From NovaOrdis Knowledge Base
Jump to: navigation, search



If a command, and optionally arguments, is specified after "exec", the command replaces the shel and no new process is created. If command cannot be executed for some reason, a non-interactive shell exits, unless the execfail shell option is enabled. In that case, it returns failure. An interactive shell returns failure if the file cannot be executed.

If -c is specified, the command is executed with an empty environment.

If -a name is supplied, the shell passes name as the zeroth argument to the executed command.

If command is not specified, any redirections take effect in the current shell, and the return status is 0. If there is a redirection error, the return status is 1.

Why wouldn't I just in-line the command in the script and use exec instead?