How to exit a Bash script from the current shell without logging out of the root user?
I have a Bash script that I start as root to execute various commands, and it keeps running until I terminate it from a case block using e.
The case block contains:
...
e)
exit
;;
...
When I select e and exit is executed, the script terminates normally, but the root user gets logged out.
I start the script with:
. /PATH/./run
so it runs in the current shell, and break, return, and kill do not work the way I want.
If I run the script in a new shell, for example:
bash /PATH/./run
then exit works normally and i return to root.
Without any further explanations about why I want to start it this way, why I am running it as root, or what else I could do.
I want to know specifically whether I can terminate the script from the case block in such a way that it returns to the shell without logging out root, and I return to my normal user shell when I start it with, without a new shell/sub-shell:
. /PATH/./run
Is this possible, yes or no?