#TIL : BASH exiting on first error

Sep 26, 2017 4 mins read

BASH exiting on first error

Setting a flag set -e to bash script will let the script exit on first error occurs, so if you want to ignore a command just adding || true to suffix

set -e

errorCmd $1 || true
echo "Run here !"

And opposite of set -e is set +e, haha of course !

set +e

errorCmd $1
echo "Still run here !"
comments powered by Disqus