Skip to content

Files

Latest commit

 

History

History
23 lines (15 loc) · 413 Bytes

bash-exiting-on-first-error.md

File metadata and controls

23 lines (15 loc) · 413 Bytes
  • Date : 2017-09-26
  • Tags : #sysadmin #bash #shell

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 !"