shell-base/script

45 lines
454 B
Plaintext
Raw Normal View History

2023-01-02 11:00:26 +01:00
#!/bin/sh
usage() {
2023-01-08 15:18:23 +01:00
printf "Usage: %s [-h]\n" "$0"
}
help() {
cat << EOH
SYNOPSIS
$0 [-h]
DESCRIPTION
$0 does things!
OPTIONS
-h Show this help
EOH
2023-01-02 11:00:26 +01:00
}
on_interrupt() {
print "Process aborted!\n"
exit 130
}
main() {
while getopts "hf:" option; do
case "${option}" in
2023-01-08 15:18:23 +01:00
h) help; exit 0;;
2023-01-02 11:00:26 +01:00
f) FOO="$OPTARG";;
*) usage; exit 1;;
esac
done
FOO="${FOO:-defaultValue}"
exit 0
}
trap on_interrupt INT
main "$@"