36 lines
464 B
Plaintext
36 lines
464 B
Plaintext
# name: getopts
|
|
# key: getopts
|
|
# --
|
|
_printhelp ()
|
|
{
|
|
cat<<EOF
|
|
Usage: \${1##*/} [OPTIONS] FILES
|
|
|
|
Options:
|
|
|
|
-h: Show this help.
|
|
|
|
EOF
|
|
}
|
|
|
|
opt_test=false
|
|
while getopts ":ht" opt; do
|
|
case \$opt in
|
|
h)
|
|
_printhelp "\$0"
|
|
exit 1 ;;
|
|
t)
|
|
opt_test=true ;;
|
|
?)
|
|
_printhelp "\$0"
|
|
exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
shift \$((\$OPTIND - 1))
|
|
|
|
if [ \$# -eq 0 ]; then
|
|
_printhelp "\$0"
|
|
exit 1
|
|
fi
|