summaryrefslogtreecommitdiff
path: root/setup-hostname.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-05-11 23:48:18 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2022-05-11 23:48:18 +0200
commit8646bb465582652dfe0f84f7dbec93979fa83170 (patch)
tree4dc7b850eaee01042e4c52b3036b215084095d87 /setup-hostname.in
parente6a59acd289efaa21d04274b75aa3073df61ef7a (diff)
downloadalpine-conf-8646bb465582652dfe0f84f7dbec93979fa83170.zip
setup-hostname: -h does not return error
running -h should return success Hide -n from help test, as it is not encouraged, but we keep it for backwards compat.
Diffstat (limited to 'setup-hostname.in')
-rw-r--r--setup-hostname.in11
1 files changed, 5 insertions, 6 deletions
diff --git a/setup-hostname.in b/setup-hostname.in
index c49e5ce..6a03457 100644
--- a/setup-hostname.in
+++ b/setup-hostname.in
@@ -2,22 +2,21 @@
PROGRAM=setup-hostname
PREFIX=@PREFIX@
-
-. $PREFIX/lib/libalpine.sh
+: ${LIBDIR=$PREFIX/lib}
+. "$LIBDIR/libalpine.sh"
usage() {
cat <<-__EOF__
- usage: setup-hostname [-h] [-n HOSTNAME]
+ usage: setup-hostname [-h] [HOSTNAME]
Sets the system hostname.
options:
-h Show this help
- -n Hostname to set non-interactively
Sets hostname to HOSTNAME or prompt if unspecified.
__EOF__
- exit 1
+ exit $1
}
@@ -43,7 +42,7 @@ valid_hostname() {
while getopts "hn:" opt; do
case $opt in
- h) usage;;
+ h) usage 0;;
n) name="$OPTARG";;
esac
done