rewrite argument parsing with the POSIX getopts shell built-in ok stsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/regress/cmdline/common.sh b/regress/cmdline/common.sh
index d982671..9c91480 100644
--- a/regress/cmdline/common.sh
+++ b/regress/cmdline/common.sh
@@ -200,26 +200,20 @@ test_cleanup()
test_parseargs()
{
- args=`getopt qr: $*`
- if [ $? -ne 0 ]; then
- echo "Supported options:"
- echo " -q: quiet mode"
- echo " -r PATH: use PATH as test data root directory"
- exit 2
- fi
- set -- $args
- while [ $# -ne 0 ]; do
- case "$1"
- in
- -q)
- export GOT_TEST_QUIET=1; shift;;
- -r)
- export GOT_TEST_ROOT="$2"; shift; shift;;
- --)
- shift; break;;
+ while getopts qr: flag; do
+ case $flag in
+ q) export GOT_TEST_QUIET=1
+ ;;
+ r) export GOT_TEST_ROOT=$OPTARG
+ ;;
+ ?) echo "Supported options:"
+ echo " -q: quiet mode"
+ echo " -r PATH: use PATH as test data root directory"
+ exit 2
+ ;;
esac
done
-}
+} >&2
run_test()
{