Skip to content

Instantly share code, notes, and snippets.

@virtualmackem
Last active October 3, 2016 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtualmackem/a3d1350e6a1d31c695a0df7a07bae4e1 to your computer and use it in GitHub Desktop.
Save virtualmackem/a3d1350e6a1d31c695a0df7a07bae4e1 to your computer and use it in GitHub Desktop.
#!/bin/bash
log() { echo $(date): $* ; } #logs date and message to stdout
die() { log $* 1>&2 ; usage ; exit 1 ; } #logs error message to stderr and exits
usage() { #logs usage info to stderr
cat <<EOF 1>&2
Usage: $0 [OPTION]...
-a this option adds bunnies
EOF
}
log "We're going to doSomething"
doSomething || die "doSomething failed"
doSomethingElse || die "doSomethingElse failed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment