Skip to content

Instantly share code, notes, and snippets.

@benmoss
Last active August 29, 2015 14:12
Show Gist options
  • Save benmoss/fe7486832e81890f3234 to your computer and use it in GitHub Desktop.
Save benmoss/fe7486832e81890f3234 to your computer and use it in GitHub Desktop.
set -e semantics
#!/bin/bash
set -e
function log_exit {
echo "exiting with status $?"
}
trap log_exit EXIT
function check_documentation_coverage {
ruby -e "exit(1)"
ruby -e "exit(0)"
}
status=0
echo "checking documentation coverage"
check_documentation_coverage || status=$?
echo "got a status of $status"
echo "checking again"
check_documentation_coverage
status=$?
echo "got a status of $status"
checking documentation coverage
got a status of 0
checking again
exiting with status 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment