The shell is gone. Once the program you executed is finished, there's nothing left for you to type at. Eahat's the terminal supposed to do with nothing running in it anymore? You can configure it to hang around so you can see the last thing output by the last thing to run in it...

 Exec has the same impact on the shell as exit - shell go bye bye - it just leaves another program in its place. 

Mark J. Reed <markjreed@gmail.com>


On Mon, Jun 3, 2024 at 10:42 Ray Andrews <rayandrews@eastlink.ca> wrote:


On 2024-06-03 07:17, Mark J. Reed wrote:
The exec builtin replaces the running shell with whatever program you run.  The point is to avoid clogging the process table with shells that are just hanging out waiting to do nothing but exit as soon as their child process finishes.
I get that. 


In your case, the script exists to set things up in the environment and then run xfce4-session; there's nothing for it to do after xfce4-session completes, so it uses exec to tidy up.

Sure.  But then what? I understand that if a script or function has nothing more to do, it may as well pre-kill itself. But the difference is that 'exec' kills the entire terminal, it doesn't just return to the prompt in a more efficient way -- which would be easy to understand, as above.  exec seems to pull the rug out from under itself, not just end a script more efficiently.  In my case, from what I've heard control seems to pass to dbus.  Mind, if dbus called the script then that's what one might expect.