Module Name:    othersrc
Committed By:   kre
Date:           Sat Sep 22 04:53:41 UTC 2018

Modified Files:
        othersrc/external/bsd/human2atf: human2atf.sh

Log Message:
Convert from getopt to getopts and fix an obvious bug with the
wayy TESTSPEC was used.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/human2atf/human2atf.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/human2atf/human2atf.sh
diff -u othersrc/external/bsd/human2atf/human2atf.sh:1.2 othersrc/external/bsd/human2atf/human2atf.sh:1.3
--- othersrc/external/bsd/human2atf/human2atf.sh:1.2	Tue May 31 20:26:58 2016
+++ othersrc/external/bsd/human2atf/human2atf.sh	Sat Sep 22 04:53:41 2018
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: human2atf.sh,v 1.2 2016/05/31 20:26:58 agc Exp $
+# $NetBSD: human2atf.sh,v 1.3 2018/09/22 04:53:41 kre Exp $
 
 # Copyright (c) 2016 Alistair Crooks <[email protected]>
 # All rights reserved.
@@ -26,33 +26,38 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
+Usage()
+{
+	printf >&2 '%s\n' "Usage: $0 [-v] [-f TestSpecFile]"
+	exit 1
+}
+
 TESTNAME=""
 TESTSPEC=Testspec
-args=$(getopt f:v $*)
-set -- $args
-while [ $# -gt 0 ]; do
-	case "$1" in
-	-f)	TESTSPEC=$2; shift ;;
-	-v)	set -x ;;
-	*)	break;
+while getopts f:v a
+do
+	case "$a" in
+	f)	TESTSPEC=$OPTARG;;
+	v)	set -x ;;
+	\?)	Usage;;
 	esac
-	shift
 done
+shift $(( $OPTIND - 1 ))
 
 case "${TESTSPEC}" in
 /*)	;;
 *)	TESTSPEC=./${TESTSPEC}
 esac
 
-if [ -e ./${TESTSPEC} ]; then
-	. ./${TESTSPEC}
+if [ -e ${TESTSPEC} ]; then
+	. ${TESTSPEC}
 else
 	echo "No Testspec file \"${TESTSPEC}\"" >&2
 	exit 1
 fi
 
 case "${TESTNAME}" in
-"")	echo "Usage: human2atf name" >&2
+"")	echo "Usage: human2atf name" >&2	# XXX Huh???
 	exit 1
 	;;
 esac

Reply via email to