eval
will run the arguments as a command in the current shell. In other words eval foo bar
is the same as just foo bar
. But variables will be expanded before executing, so we can execute commands saved in shell variables
exec
does not create a new process. It replaces the current process with the new command. If you did this on the command line then it will effectively end your shell session (and maybe log you out or close the terminal window!)
$ eval x=42
$ echo $x
42
$ exec x=42
bash: exec: x=42: not found
Comments
Post a Comment