How to add set -e to all default bashes?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
To make a bash script exit after any failed command, you can add
set -e
Imagine, you have a CI agent which allow people to embed bash scripts as tasks in build jobs.
How to make the exit behaviour given by set -e default for all new bash instances? Is there some sort of bashrc hack for that?
bash error-handling
add a comment |Â
up vote
0
down vote
favorite
To make a bash script exit after any failed command, you can add
set -e
Imagine, you have a CI agent which allow people to embed bash scripts as tasks in build jobs.
How to make the exit behaviour given by set -e default for all new bash instances? Is there some sort of bashrc hack for that?
bash error-handling
1
PuttingSHELLOPTS=errexitin the environment would do it, but in my opinion and that of manyset -eis almost never the right way to do error handling.
â Stéphane Chazelas
Feb 1 at 19:56
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
To make a bash script exit after any failed command, you can add
set -e
Imagine, you have a CI agent which allow people to embed bash scripts as tasks in build jobs.
How to make the exit behaviour given by set -e default for all new bash instances? Is there some sort of bashrc hack for that?
bash error-handling
To make a bash script exit after any failed command, you can add
set -e
Imagine, you have a CI agent which allow people to embed bash scripts as tasks in build jobs.
How to make the exit behaviour given by set -e default for all new bash instances? Is there some sort of bashrc hack for that?
bash error-handling
edited Feb 1 at 19:42
asked Feb 1 at 19:19
J. Doe
1033
1033
1
PuttingSHELLOPTS=errexitin the environment would do it, but in my opinion and that of manyset -eis almost never the right way to do error handling.
â Stéphane Chazelas
Feb 1 at 19:56
add a comment |Â
1
PuttingSHELLOPTS=errexitin the environment would do it, but in my opinion and that of manyset -eis almost never the right way to do error handling.
â Stéphane Chazelas
Feb 1 at 19:56
1
1
Putting
SHELLOPTS=errexit in the environment would do it, but in my opinion and that of many set -e is almost never the right way to do error handling.â Stéphane Chazelas
Feb 1 at 19:56
Putting
SHELLOPTS=errexit in the environment would do it, but in my opinion and that of many set -e is almost never the right way to do error handling.â Stéphane Chazelas
Feb 1 at 19:56
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You can make the present running bash shell activate the -e option with:
$ set -e
Just to confirm:
$ echo "$-"
himBHs
$ set -e
ehimBHs
As the bashrc file is sourced to interactive shells you can make all new bash shells use the -e option by adding this:
set -e
As one line at any place (that is executed) of the .bashrc script.
This is a very bad idea however, as there are many conditions under which the detection of a failed command fails and there are several cases where a failed command is desirable. Please read
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can make the present running bash shell activate the -e option with:
$ set -e
Just to confirm:
$ echo "$-"
himBHs
$ set -e
ehimBHs
As the bashrc file is sourced to interactive shells you can make all new bash shells use the -e option by adding this:
set -e
As one line at any place (that is executed) of the .bashrc script.
This is a very bad idea however, as there are many conditions under which the detection of a failed command fails and there are several cases where a failed command is desirable. Please read
add a comment |Â
up vote
1
down vote
accepted
You can make the present running bash shell activate the -e option with:
$ set -e
Just to confirm:
$ echo "$-"
himBHs
$ set -e
ehimBHs
As the bashrc file is sourced to interactive shells you can make all new bash shells use the -e option by adding this:
set -e
As one line at any place (that is executed) of the .bashrc script.
This is a very bad idea however, as there are many conditions under which the detection of a failed command fails and there are several cases where a failed command is desirable. Please read
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can make the present running bash shell activate the -e option with:
$ set -e
Just to confirm:
$ echo "$-"
himBHs
$ set -e
ehimBHs
As the bashrc file is sourced to interactive shells you can make all new bash shells use the -e option by adding this:
set -e
As one line at any place (that is executed) of the .bashrc script.
This is a very bad idea however, as there are many conditions under which the detection of a failed command fails and there are several cases where a failed command is desirable. Please read
You can make the present running bash shell activate the -e option with:
$ set -e
Just to confirm:
$ echo "$-"
himBHs
$ set -e
ehimBHs
As the bashrc file is sourced to interactive shells you can make all new bash shells use the -e option by adding this:
set -e
As one line at any place (that is executed) of the .bashrc script.
This is a very bad idea however, as there are many conditions under which the detection of a failed command fails and there are several cases where a failed command is desirable. Please read
answered Feb 1 at 19:25
Isaac
6,6371734
6,6371734
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f421272%2fhow-to-add-set-e-to-all-default-bashes%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Putting
SHELLOPTS=errexitin the environment would do it, but in my opinion and that of manyset -eis almost never the right way to do error handling.â Stéphane Chazelas
Feb 1 at 19:56