Browse Source

Add a proper usage() function.

Suggested by and OK jmc.
OK tb
OPENBSD_6_4
rpe 6 years ago
parent
commit
728f495514
1 changed files with 9 additions and 7 deletions
  1. +9
    -7
      src/etc/netstart

+ 9
- 7
src/etc/netstart View File

@ -1,10 +1,16 @@
#!/bin/sh - #!/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. # Turn off Strict Bourne shell mode.
set +o sh 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 # Echo file $1 to stdout. Skip comment lines and delete everything
# after the first '#' from other lines. Strip leading and trailing # after the first '#' from other lines. Strip leading and trailing
# whitespace if IFS is set. # whitespace if IFS is set.
@ -200,23 +206,19 @@ FUNCS_ONLY=1 . /etc/rc.d/rc.subr
_rc_parse_conf _rc_parse_conf
PRINT_ONLY=false PRINT_ONLY=false
USAGE="usage: ${0##*/} [[-n] interface ...]"
V4_DHCPCONF=false V4_DHCPCONF=false
V6_AUTOCONF=false V6_AUTOCONF=false
while getopts ":n" opt; do while getopts ":n" opt; do
case $opt in case $opt in
n) PRINT_ONLY=true;; n) PRINT_ONLY=true;;
*) print -u2 "$USAGE"; exit 1;;
*) usage;;
esac esac
done done
shift $((OPTIND-1)) shift $((OPTIND-1))
# Option -n is only supported if interface names are specified as parameters. # 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 # Load key material for the generation of IPv6 Semantically Opaque Interface
# Identifiers (SOII) used for link local and SLAAC addresses. # Identifiers (SOII) used for link local and SLAAC addresses.


Loading…
Cancel
Save