Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc/stand/binstall Convert from getopt to getopts...



details:   https://anonhg.NetBSD.org/src/rev/32b0ce512655
branches:  trunk
changeset: 433575:32b0ce512655
user:      kre <kre%NetBSD.org@localhost>
date:      Sat Sep 22 03:29:51 2018 +0000

description:
Convert from getopt to getopts    (script is slightly smaller as a
result, but not enough to save a block ... but if /usr/bin/getopt is
not used elsewhere, and it should not be, it will no longer be required.)

diffstat:

 sys/arch/sparc/stand/binstall/binstall.sh |  33 +++++++++++++-----------------
 1 files changed, 14 insertions(+), 19 deletions(-)

diffs (51 lines):

diff -r 0ca80d2efa99 -r 32b0ce512655 sys/arch/sparc/stand/binstall/binstall.sh
--- a/sys/arch/sparc/stand/binstall/binstall.sh Fri Sep 21 18:38:25 2018 +0000
+++ b/sys/arch/sparc/stand/binstall/binstall.sh Sat Sep 22 03:29:51 2018 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-#      $NetBSD: binstall.sh,v 1.17 2018/09/16 14:26:04 kre Exp $
+#      $NetBSD: binstall.sh,v 1.18 2018/09/22 03:29:51 kre Exp $
 #
 
 vecho () {
@@ -53,27 +53,22 @@
 : ${OFWBOOTBLK:=ofwboot}
 [ "$( sysctl -n machdep.cpu_arch )" = 9 ] && ULTRASPARC=true || ULTRASPARC=false
 
-### XXX this should be converted to use getopts
-set -- $(getopt "b:hf:i:m:tUuv" "$@" )
-if [ $? -gt 0 ]; then
-       Usage
-fi
-
-for a
+while getopts b:hf:i:m:tUuv a
 do
-       case "$1" in
-       -h) Help; shift ;;
-       -u) ULTRASPARC=true; shift ;;
-       -U) ULTRASPARC=false; shift ;;
-       -b) BOOTPROG=$2; OFWBOOTBLK=$2; shift 2 ;;
-       -f) DEV=$2; shift 2 ;;
-       -m) MDEC=$2; shift 2 ;;
-       -i) INSTALLBOOT=$2; shift 2 ;;
-       -t) TEST=1; VERBOSE=-v; shift ;;
-       -v) VERBOSE=-v; shift ;;
-       --) shift; break ;;
+       case "$a" in
+       h) Help;;
+       u) ULTRASPARC=true;;
+       U) ULTRASPARC=false;;
+       b) BOOTPROG=$OPTARG; OFWBOOTBLK=$OPTARG;;
+       f) DEV=$OPTARG;;
+       m) MDEC=$OPTARG;;
+       i) INSTALLBOOT=$OPTARG;;
+       t) TEST=1; VERBOSE=-v;;
+       v) VERBOSE=-v;;
+       \?) Usage;;
        esac
 done
+shift $(( $OPTIND - 1 ))
 
 if [ "$( sysctl -n kern.securelevel )" -gt 0 ] && ! [ -f "$DEV" ]; then
        Secure



Home | Main Index | Thread Index | Old Index