Created
January 6, 2015 19:19
-
-
Save pontikos/73d899091c540c991012 to your computer and use it in GitHub Desktop.
Error functions for bash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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