Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/sys_info Parse the arguments to sys_info(1) a bit di...
details: https://anonhg.NetBSD.org/src/rev/3226cb0000a8
branches: trunk
changeset: 355875:3226cb0000a8
user: agc <agc%NetBSD.org@localhost>
date: Sat Aug 19 18:36:31 2017 +0000
description:
Parse the arguments to sys_info(1) a bit differently, using getopts(1)
Thanks to Paul Goyette for the nudge
diffstat:
usr.bin/sys_info/sys_info.sh | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diffs (42 lines):
diff -r 5704252e4e9d -r 3226cb0000a8 usr.bin/sys_info/sys_info.sh
--- a/usr.bin/sys_info/sys_info.sh Sat Aug 19 14:22:49 2017 +0000
+++ b/usr.bin/sys_info/sys_info.sh Sat Aug 19 18:36:31 2017 +0000
@@ -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@localhost>
# All rights reserved.
@@ -122,20 +122,21 @@
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
Home |
Main Index |
Thread Index |
Old Index