Is there any way to exit a script and then stay in the terminal?

Is there any way to exit a script and then stay in 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

What’s the best way to exit a bash script?

You use exit code inside run while source your run2.sh file in the bash tty. If the give the run function its power to exit your script and give the run2.sh its power to exit the terminator. Then of cuz the run function has power to exit your teminator.

How to terminate the current script in PowerShell?

Terminate the current Powershell script. Way 1 – Exit. Exit without exit code. Exit with code 0. Exit with code 1. Way 2 – Break. Break with an UnknownLabel terminates the script directly. But it terminates also the caller script. Terminate the current Powershell session.

Is there a way to exit a batch file?

Prepare your party hats: Batch File Week is almost over. In your batch file, you may want to exit batch file processing (say, you encountered an error and want to give up), but if you use the exit command, that will exit the entire command processor. Which is probably not what you intended.

How does SIGHUP relate to other termination signals?

SIGHUP, as you say, is intended to indicate that the terminal connection has been lost, rather than to be a termination signal as such. But, again, the default action for SIGHUP (if the process does not catch or ignore it) is to terminate the process in the same way as SIGTERM etc..

How does SIGINT relate to the other termination signals such as SIGTERM?

Using kill (both the system call and the utility` you can send almost any signal to any process, given you’ve got the permission. A process cannot distinguish how a signal came to life and who has sent it. That being said, SIGINT really is meant to singal the Ctrl-C interruption, while SIGTERM is the general terminal signal.

How to keep the command prompt from closing?

How to keep Command Prompt from Closing 1 Open the batch file in Notepad by right clicking on it and click on “Edit” from the list. 2 The second way I am going to show you is also a simple method. 3 You can prevent Command Prompt window from closing after running commands through adding a Registry Key in the Windows Registry. See More….

How to exit Bash with the return value n?

As §4.1 “Bourne Shell Builtins” of the Bash Reference Manual puts it: Cause a shell function to exit with the return value n. If n is not supplied, the return value is the exit status of the last command executed in the function.