summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorRobert Peichaer <rpe@cvs.openbsd.org>2018-04-28 22:38:33 +0000
committerRobert Peichaer <rpe@cvs.openbsd.org>2018-04-28 22:38:33 +0000
commit4539bdec23a59b9e899286daad9e6d68c07f79ee (patch)
tree5d30d64e58ff0c0755ad3ce91075be260cbfe006 /etc
parent5f8123e01363b1e8c6bb73b1b4ae30218235ae03 (diff)
Add a proper usage() function.
Suggested by and OK jmc. OK tb
Diffstat (limited to 'etc')
-rw-r--r--etc/netstart16
1 files changed, 9 insertions, 7 deletions
diff --git a/etc/netstart b/etc/netstart
index 4216e54ada8..6e3fb80848d 100644
--- a/etc/netstart
+++ b/etc/netstart
@@ -1,10 +1,16 @@
#!/bin/sh -
#
-# $OpenBSD: netstart,v 1.197 2018/03/04 10:12:26 jmc Exp $
+# $OpenBSD: netstart,v 1.198 2018/04/28 22:38:32 rpe Exp $
# Turn off Strict Bourne shell mode.
set +o sh
+# Show usage of the netstart script and exit.
+usage() {
+ print -u2 "usage: ${0##*/} [[-n] interface ...]"
+ exit 1
+}
+
# Echo file $1 to stdout. Skip comment lines and delete everything
# after the first '#' from other lines. Strip leading and trailing
# whitespace if IFS is set.
@@ -200,23 +206,19 @@ FUNCS_ONLY=1 . /etc/rc.d/rc.subr
_rc_parse_conf
PRINT_ONLY=false
-USAGE="usage: ${0##*/} [[-n] interface ...]"
V4_DHCPCONF=false
V6_AUTOCONF=false
while getopts ":n" opt; do
case $opt in
n) PRINT_ONLY=true;;
- *) print -u2 "$USAGE"; exit 1;;
+ *) usage;;
esac
done
shift $((OPTIND-1))
# Option -n is only supported if interface names are specified as parameters.
-if $PRINT_ONLY && (($# == 0)); then
- print -u2 "$USAGE"
- exit 1
-fi
+$PRINT_ONLY && (($# == 0)) && usage
# Load key material for the generation of IPv6 Semantically Opaque Interface
# Identifiers (SOII) used for link local and SLAAC addresses.