Last active
July 5, 2018 23:21
-
-
Save andersy005/2901025c2f460326a9bd7613357a36bc 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
#!/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