When I use exit command in a shell script, the script will terminate the terminal (the prompt). Is there a way to terminate a script and then staying in the terminal?
My script run.sh is expected to execute by directly being sourced, or sourced from another script.
To be more specific, there are two scripts, run2.sh as
...
. run.sh
echo "place A"
...
and run.sh as
...
exit
...
when I run it by . run2.sh, and if it hit exit codeline in run.sh, I want it to stop to the terminal and stay there. But using exit, the whole terminal gets closed.
PS: I have tried to use return, but echo codeline will still gets executed...
exit 0to terminate the script after success, when you run your script ex:./test.shyou should see the output but your console will remain open.shellcommand, that opens in fact a shell terminal. My own experience however is that this doesn't happen withexit. Exit normally gives back the control to the parent script.