hook_error() { local ret=$? trap - 18 [ $ret -ne 0 ] && { echo ERROR: $ret exit 1 } trap hook_error 18 }; hook_error