Bash exec: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * bash =Overview=")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
=Internal=
=Internal=


* [[bash#Commands|bash]]
* [[Bash#Built-In_Commands|bash]]


=Overview=
=Overview=
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?=
<font color=darkgray>TODO</font>

Latest revision as of 05:52, 14 May 2019

Internal

Overview

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?

TODO