I know that this is probably a relatively pointless question, but I am curious as to why exec false
closes the terminal just like exit
does.
I would also like to know if this is a acceptable way to close the terminal or not.
command line
I know that this is probably a relatively pointless question, but I am curious as to why exec false
closes the terminal just like exit
does.
I would also like to know if this is a acceptable way to close the terminal or not.
Best Answer
exec false
is replacing the current shell by the execution of the commandfalse
(here not the shell builtin but/bin/false
or whateverfalse
executable that comes first in thePATH
) which quickly exits. If the shell was the topmost process running in your terminal emulator, there are no more processes running inside it so the terminal emulator is closed.This is a an acceptable alternate way to close a terminal, just like would be many similar commands:
See also: what-does-an-exec-command-do