From: Ondřej Surý Date: Fri, 24 Apr 2020 11:34:40 +0000 (+0200) Subject: Remove the requirement for GNU getopt and parse long options using getopts X-Git-Tag: v9.17.2~121^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d10294acb37f7683b2032ef2300cf5644d33a79c;p=thirdparty%2Fbind9.git Remove the requirement for GNU getopt and parse long options using getopts --- diff --git a/bin/tests/system/system-test-driver.sh.in b/bin/tests/system/system-test-driver.sh.in index 6ad8380643a..edffd7be229 100644 --- a/bin/tests/system/system-test-driver.sh.in +++ b/bin/tests/system/system-test-driver.sh.in @@ -9,21 +9,6 @@ usage() { echo "$0 --test-name=NAME --log-file=PATH.log --trs-file=PATH.trs --color-tests={yes|no} --expect-failure={yes|no} --enable-hard-errors={yes|no}" } -# -# This requires GNU getopt -# -getopt --test >/dev/null -if [ "$?" -ne 4 ]; then - echo "fatal: GNU getopt is required" - exit 1 -fi - -OPTS=$(getopt --shell sh --name "$(basename "$0")" --options '' --longoptions test-name:,log-file:,trs-file:,color-tests:,expect-failure:,enable-hard-errors: -- "$@") - -if [ "$?" -ne 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi - -eval set -- "$OPTS" - TEST_NAME= LOG_FILE= TRS_FILE= @@ -31,18 +16,23 @@ COLOR_TESTS=yes EXPECT_FAILURE=no HARD_ERRORS=yes -while true; do - case "$1" in - --test-name ) TEST_NAME="$2"; shift; shift ;; - --log-file ) LOG_FILE="$2"; shift; shift ;; - --trs-file ) TRS_FILE="$2"; shift; shift ;; - --color-tests ) COLOR_TESTS="$2"; shift; shift ;; - --expect-failure ) EXPECT_FAILURE="$2"; shift; shift ;; - --hard-errors ) HARD_ERRORS="$2"; shift; shift ;; - -- ) shift; break ;; - *) break ;; - esac +while getopts -: OPT; do + if [ "$OPT" = "-" ] && [ -n "$OPTARG" ]; then + OPT="${OPTARG%%=*}" + OPTARG="${OPTARG#$OPT}" + OPTARG="${OPTARG#=}" + fi + case "$OPT" in + test-name) TEST_NAME="$OPTARG" ;; + log-file) LOG_FILE="$OPTARG" ;; + trs-file) TRS_FILE="$OPTARG" ;; + color-tests) COLOR_TESTS="$OPTARG" ;; + expect-failure) EXPECT_FAILURE="$OPTARG" ;; + hard-errors) HARD_ERRORS="$OPTARG" ;; + *) break ;; + esac done +shift $((OPTIND-1)) if [ -z "$1" ]; then echo "fatal: test name required"