Does running exec
in an interactive shell do anything? I mean simply exec
, with no parameters whatsoever.
What about in a script?
If it does do something, what does it do?
Does running exec
in an interactive shell do anything? I mean simply exec
, with no parameters whatsoever.
What about in a script?
If it does do something, what does it do?
If command is not specified, any redirections can take effect in the current shell. This is short version of what man page says .That I understand as when exec
is executed empty it does not start a new shell , does not make changes in the current, and returns code 0 which means it was executed without errors.
Yes:
Normally when you run a command, it calls fork
and exec
(plus pipe, etc). But when you add exec
at the start (e.g. exec ls
), it does not call fork
, therefore the shell is replaced by the command. That is the command runs in the same process as the shell was in (the shell no longer exists).
It applies redirections, that are then in affect afterward.