I've been doing a lot of scripting and improved my skills quite a bit, but one problem I'm running into is understanding the differences between exiting a script vs exiting a terminal or shell.
I've written a nice set of bash functions that test input from read commands and use return
to exit the script back to a prompt, and it works well in those sourced function instances.
But, I have other scripts, some that I've tried to setup to launch from different places such as launching the executable script with [scriptname] from an open terminal vs using a launch script which opens a terminal and calls [scriptname] script. The latter I've written so they can be clicked to run from a file manager, or called from a desktop file (though I can also use the terminal=true
method in a desktop file.)
In working these two scenarios I began exiting some scripts with the bash
command, to keep the terminal open as opposed to exit
which closes the terminal.
The truth is I just don't understand the workings of the shell, subshell, script interaction, and that has gotten me into trouble.
After ediiting and repeatedly running these scripts from a single terminal instance on two occassions, I seem to get some kind of loop going and my cpu starts racing, the temperature pops up hot, the desktop becomes mostly unresponsive, and I have to do a hard shutdown. I can not say for certain it's these scripts causing that, but my gut says it is.
Could someone point me to an easy way to understand when and how to use the various script/terminal exit commands?