From 728f495514662966af30252eece6527a2171e6e7 Mon Sep 17 00:00:00 2001 From: rpe <> Date: Sat, 28 Apr 2018 22:38:32 +0000 Subject: [PATCH] Add a proper usage() function. Suggested by and OK jmc. OK tb --- src/etc/netstart | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/etc/netstart b/src/etc/netstart index 4216e54a..6e3fb808 100644 --- a/src/etc/netstart +++ b/src/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.