Module Name: src Committed By: agc Date: Sat Aug 19 18:36:31 UTC 2017
Modified Files: src/usr.bin/sys_info: sys_info.sh Log Message: Parse the arguments to sys_info(1) a bit differently, using getopts(1) Thanks to Paul Goyette for the nudge To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/sys_info/sys_info.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/sys_info/sys_info.sh diff -u src/usr.bin/sys_info/sys_info.sh:1.2 src/usr.bin/sys_info/sys_info.sh:1.3 --- src/usr.bin/sys_info/sys_info.sh:1.2 Sat Aug 19 03:06:50 2017 +++ src/usr.bin/sys_info/sys_info.sh Sat Aug 19 18:36:31 2017 @@ -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 <a...@netbsd.org> # All rights reserved. @@ -122,20 +122,21 @@ getversion() { 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 if ${all}; then