When I use exit
command in a shell script, the script will terminate the terminal (the prompt). Is there any 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.
EDIT:
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 0
to terminate the script after success, when you run your script ex:./test.sh
you should see the output but your console will remain open. – Ben Ashtonshell
command, 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. – Willem Van Onsem