shell - Bash: stop on error in sourced script -


in shell script executed, can abort on errors using set -e.

in sourced script, however, using set -e kill original shell if later command exits error status.

source set_e.sh ./exit_1.sh # shell dies 

a trivial solution set +e @ end of script, break parent's set -e if used (which may happen if wraps script in future).

how can abort-on-error functionality in sourced script?

it's impossible. can opt use subshell if want:

(     set -e     source another.sh ) 

only environment of calling script can never altered called script.

note: may important separate both commands newline , not use semicolon.


Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -