Sat Aug 19 18:36:31 2017 UTC ()
Parse the arguments to sys_info(1) a bit differently, using getopts(1)

Thanks to Paul Goyette for the nudge


(agc)
diff -r1.2 -r1.3 src/usr.bin/sys_info/sys_info.sh

cvs diff -r1.2 -r1.3 src/usr.bin/sys_info/sys_info.sh (expand / switch to context diff)
--- src/usr.bin/sys_info/sys_info.sh 2017/08/19 03:06:50 1.2
+++ src/usr.bin/sys_info/sys_info.sh 2017/08/19 18:36:31 1.3
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: sys_info.sh,v 1.2 2017/08/19 03:06:50 agc Exp $
+# $NetBSD: sys_info.sh,v 1.3 2017/08/19 18:36:31 agc Exp $
 
 # Copyright (c) 2016 Alistair Crooks <agc@NetBSD.org>
 # All rights reserved.
@@ -122,19 +122,20 @@
 	esac
 }
 
-case $# in
-0)	all=true ;;
-*)	all=false ;;
-esac
-
-while [ $# -gt 0 ]; do
-	case "$1" in
-	-a)	all=true ;;
-	-v)	set -x ;;
+all=false
+while getopts "av" a; do
+	case "${a}" in
+	a)	all=true ;;
+	v)	set -x ;;
 	*)	break ;;
 	esac
 	shift
 done
+
+# if no arg specified, we want them all
+if [ $# -eq 0 ]; then
+	all=true
+fi
 
 # if we want to do every one, then let's get the arguments
 # not really scalable