meta data for this page
  •  

BASH: Error handling

function exit on error

Construction similar to try-catch:

task() {
  ( 
    set -e
    set -o pipefail
    echo "task() started"
    do_command1 ${1} ${2} && banner OK || banner ERROR
    do_command2 ${1} ${2} && banner OK || banner ERROR
    build_cmd_step_1
  build_cmd_step_2
  build_cmd_step_3
  ...
)}
 
task param1 param2