Skip to content

Instantly share code, notes, and snippets.

@pontikos
Created January 6, 2015 19:19
Show Gist options
  • Select an option

  • Save pontikos/73d899091c540c991012 to your computer and use it in GitHub Desktop.

Select an option

Save pontikos/73d899091c540c991012 to your computer and use it in GitHub Desktop.
Error functions for bash.
# prints to stderr in red
function error() { >&2 echo -e "\033[31m$*\033[0m"; }
function stop() { error "$*"; exit 1; }
try() { "$@" || stop "cannot $*"; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment