2

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?

1

2 Answers 2

3

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.

3

Yes:

When called with a command as argument.

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).

When called without a command.

It applies redirections, that are then in affect afterward.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .