Any way to exit bash script, but not quitting the terminal

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….

17 Answers
17

Leave a Comment