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