Created
September 14, 2016 13:29
-
-
Save mrqaidi/7511d189caefd5fbce95f0a641bd4f6d to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
usage="$(basename "$0") [-h] [-s n] -- program to calculate the answer to life, the universe and everything | |
where: | |
-h show this help text | |
-s set the seed value (default: 42)" | |
seed=42 | |
while getopts ':hs:' option; do | |
case "$option" in | |
h) echo "$usage" | |
exit | |
;; | |
s) seed=$OPTARG | |
;; | |
:) printf "missing argument for -%s\n" "$OPTARG" >&2 | |
echo "$usage" >&2 | |
exit 1 | |
;; | |
\?) printf "illegal option: -%s\n" "$OPTARG" >&2 | |
echo "$usage" >&2 | |
exit 1 | |
;; | |
esac | |
done | |
shift $((OPTIND - 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment