summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-05-12 12:31:36 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2022-05-12 12:31:36 +0200
commit5ae5d03c986fb0e8ef7ae2f6e7f94eca3a2c513a (patch)
treeb703b7795bfcd4043361d2003c6d8a6f43bd29e0
parent1c5c4564f9b656949cc9ee3f83e548a6a67c7e09 (diff)
downloadalpine-conf-5ae5d03c986fb0e8ef7ae2f6e7f94eca3a2c513a.zip
setup-dns: fix exitstatus and usage text for -h
send usage to std err on invalid option exit with success with -h
-rw-r--r--setup-dns.in10
1 files 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))