Exiting, quitting, or halting refers to the termination of a process or program.
Questions tagged [exit]
2585 questions
2467
votes
16 answers
How to leave/exit/deactivate a Python virtualenv
I'm using virtualenv and the virtualenvwrapper. I can switch between virtualenv's just fine using the workon command.
me@mymachine:~$ workon env1
(env1)me@mymachine:~$ workon env2
(env2)me@mymachine:~$ workon env1
(env1)me@mymachine:~$
How do I…

Apreche
- 30,042
- 8
- 41
- 52
930
votes
9 answers
In a Bash script, how can I exit the entire script if a certain condition occurs?
I'm writing a script in Bash to test some code. However, it seems silly to run the tests if compiling the code fails in the first place, in which case I'll just abort the tests.
Is there a way I can do this without wrapping the entire script inside…

samoz
- 56,849
- 55
- 141
- 195
809
votes
8 answers
Automatic exit from Bash shell script on error
I've been writing some shell script and I would find it useful if there was the ability to halt the execution of said shell script if any of the commands failed. See below for an example:
#!/bin/bash
cd some_dir
./configure…

radman
- 17,675
- 11
- 42
- 58
764
votes
17 answers
What are the differences in die() and exit() in PHP?
What are the differences between die() and exit() functions in PHP?
I think both have the same functionality, but I doubt there is something different in both... what is it?

coderex
- 27,225
- 45
- 116
- 170
537
votes
11 answers
Difference between return and exit in Bash functions
What is the difference between the return and exit statement in Bash functions with respect to exit codes?

lecodesportif
- 10,737
- 9
- 38
- 58
529
votes
3 answers
Difference between exit() and sys.exit() in Python
In Python, there are two similarly-named functions, exit() and sys.exit(). What's the difference and when should I use one over the other?

Drake Guan
- 14,514
- 15
- 67
- 94
389
votes
22 answers
SQL Server - stop or break execution of a SQL script
Is there a way to immediately stop execution of a SQL script in SQL server, like a "break" or "exit" command?
I have a script that does some validation and lookups before it starts doing inserts, and I want it to stop if any of the validations or…

Andy White
- 86,444
- 48
- 176
- 211
332
votes
4 answers
What is the command to exit a console application in C#?
What is the command in C# for exiting a console application?

Sababoni
- 4,875
- 4
- 20
- 21
307
votes
10 answers
How to exit from Python without traceback?
I would like to know how to I exit from Python without having an traceback dump on the output.
I still want want to be able to return an error code but I do not want to display the traceback log.
I want to be able to exit using exit(number) without…

sorin
- 161,544
- 178
- 535
- 806
299
votes
9 answers
How to exit if a command failed?
I am a noob in shell-scripting. I want to print a message and exit my script if a command fails. I've tried:
my_command && (echo 'my_command failed; exit)
but it does not work. It keeps executing the instructions following this line in the script.…

user459246
- 3,139
- 2
- 15
- 7
275
votes
16 answers
Checking Bash exit status of several commands efficiently
Is there something similar to pipefail for multiple commands, like a 'try' statement but within bash. I would like to do something like this:
echo "trying stuff"
try {
command1
command2
command3
}
And at any point, if any command fails,…

jwbensley
- 10,534
- 19
- 75
- 93
267
votes
5 answers
How do I properly exit a C# application?
I have a published application in C#. Whenever I close the main form by clicking on the red exit button, the form closes but not the whole application. I found this out when I tried shutting down the computer and was subsequently bombarded by lots…

John Ernest Guadalupe
- 6,379
- 11
- 38
- 71
240
votes
10 answers
How do I step out of a loop with Ruby Pry?
I'm using Pry with my Rails application. I set binding.pry inside a loop in my model to try and debug a problem. For example:
(1..100).each do |i|
binding.pry
puts i
end
When I type quit, it goes to the next iteration and stops again. Is there…

Ryan
- 9,340
- 5
- 39
- 42
237
votes
25 answers
How to terminate the script in JavaScript?
How can I exit the JavaScript script much like PHP's exit or die? I know it's not the best programming practice but I need to.

Nir
- 24,619
- 25
- 81
- 117
237
votes
3 answers
How to undo the effect of "set -e" which makes bash exit immediately if any command fails?
After entering set -e in an interactive bash shell, bash will exit immediately if any command exits with non-zero. How can I undo this effect?

Tianyi Cui
- 3,933
- 3
- 21
- 18