Skip to content

Instantly share code, notes, and snippets.

@manboubird
Created January 18, 2015 14:32
Show Gist options
  • Save manboubird/64aaf6b42529b59ae8a5 to your computer and use it in GitHub Desktop.
Save manboubird/64aaf6b42529b59ae8a5 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o pipefail # Trace errors through pipes
set -o errtrace # Trace ERR through 'time command'
error() {
JOB="$0" # job name
LASTLINE="$1" # line of error occurrence
LASTERR="$2" # error code
echo "ERROR in ${JOB}:line ${LASTLINE} - exit code ${LASTERR}"
exit 1
}
trap 'error ${LINENO} ${$?}' ERR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment