Closed lectrode closed 2 years ago
LGTM, make sense, thanks.
Thanks guys, yes makes a lot of sense. Just one question, if we don't add :
as the first char of getopts
, then we get the desired behavior for unrecognized options by default, correct? Am I not missing anything?
What do you think of this?
--- a/checkrebuild
+++ b/checkrebuild
@@ -9,19 +9,18 @@ shopt -s extglob
log="$(mktemp -d)"
trap 'rm -rf "$log"' EXIT
+exit_usage() {
+ echo "Usage: $0 [-v] [-i repo1] [-i repo2]"
+ exit "$1"
+}
+
verbose=0
-while getopts ":hvi:" OPTION; do
+while getopts "hvi:" OPTION; do
case $OPTION in
v) verbose=1 ;;
i) include+=("$OPTARG") ;;
- h)
- echo "Usage: $(basename $0) [-v] [-i repo1] [-i repo2]"
- exit 0
- ;;
- *) echo "Unrecognized parameter: $OPTARG"
- echo "Usage: $(basename $0) [-v] [-i repo1] [-i repo2]"
- exit 1
- ;;
+ h) exit_usage 0 ;;
+ *) exit_usage 1 ;;
esac
done
(if so would also drop the basename
for consistency with the default behavior)
I have no objection to those adjustments. Tested, works as expected
Ok cool! Let's have your name in the contributors, please apply and I'll merge right away 😉
not critical, but a nice-to-have
addresses issue #22