Created
May 24, 2020 01:20
-
-
Save micha/a003924ae5a7928ce6f30232ce0e318b to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
prog=$0 | |
warn() { [ $# -gt 0 ] && echo $prog: "$@" 1>&2; } | |
abort() { warn "$@"; exit 1; } | |
usage() { | |
warn "$@" | |
cat <<EOT | |
USAGE: $(basename $prog) [-h] | |
Prints "hello world" to stdout. | |
OPTIONS: | |
-h Print this and exit. | |
EOT | |
exit; | |
} | |
while getopts "h" o; do | |
case "${o}" in | |
h) usage ;; | |
?) abort ;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
echo hello world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment