set -e

# failed() {
#   ret="$?"
#   test "${ret:?}" != '0' \
#     && echo "Error occurred:" \
#     && awk 'NR>L-4 && NR<L+4 { printf "%-5d%3s%s\n",NR,(NR==L?">>>":""),$0 }' L="$1" "$0"
# }
# trap 'failed "${LINENO}"' HUP INT INT QUIT TERM EXIT # ERR

trap_error() {
  ret="$?"
  [ "${ret}" != '0' ] \
    && printf '%b\n' "\nERROR line ${1}: Command exited with status ${ret:?}"
}
trap 'trap_error ${LINENO}' HUP INT QUIT TERM EXIT

echo "Beginning experiment"
# false || true
# false
echo "Proceeding to Normal Exit"
true
