From 5ae5d03c986fb0e8ef7ae2f6e7f94eca3a2c513a Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 12 May 2022 12:31:36 +0200 Subject: setup-dns: fix exitstatus and usage text for -h send usage to std err on invalid option exit with success with -h --- setup-dns.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup-dns.in b/setup-dns.in index 85b6a1c..84f2e96 100644 --- a/setup-dns.in +++ b/setup-dns.in @@ -1,11 +1,12 @@ #!/bin/sh PREFIX=@PREFIX@ -. "$PREFIX/lib/libalpine.sh" +: ${LIBDIR=$PREFIX/lib} +. "$LIBDIR/libalpine.sh" usage() { cat <<-__EOF__ - usage: setup-dns [-h] [-d domain name] [IPADDR...] + usage: setup-dns [-h] [-d DOMAINNAME] [IPADDR...] Setup ${ROOT}etc/resolv.conf DNS settings @@ -15,14 +16,15 @@ usage() { The optional IPADDR are a list of DNS servers to use. __EOF__ - exit 1 + exit $1 } while getopts "d:n:h" opt; do case $opt in d) DOMAINNAME="$OPTARG";; - h) usage;; + h) usage 0;; n) NAMESERVERS="$OPTARG";; + '?') usage "1" >&2;; esac done shift $(($OPTIND - 1)) -- cgit v1.2.3