[__hostame] Resolve shellcheck errors

This commit is contained in:
Dennis Camera 2019-10-25 02:16:43 +02:00
parent d4313c7501
commit b65ceba569
2 changed files with 6 additions and 6 deletions

View File

@ -55,18 +55,18 @@ fi
################################################################################
# Setup hostname
#
echo 'changed' >> "$__messages_out"
echo 'changed' >>"$__messages_out"
# First try to set the hostname using hostnamectl, if available.
if [ "$has_hostnamectl" ]; then
if [ -n "$has_hostnamectl" ]; then
# Allow hostnamectl to fail silently.
# Who the fuck invented a tool that needs dbus to set the hostname anyway…
# NOTE: We write the static hostname to /etc/hostname first in case
# hostnamectl fails. Fallback-code below will then adjust the running
# hostname below.
echo "printf '%s\\n' '$name_should' > /etc/hostname"
echo "echo '$name_should' >/etc/hostname"
echo "hostnamectl set-hostname '$name_should' && exit 0"
fi
@ -75,7 +75,7 @@ fi
case $os
in
alpine|archlinux|debian|devuan|ubuntu)
echo "printf '%s\\n' '$name_should' > /etc/hostname"
echo "echo '$name_should' >/etc/hostname"
echo "hostname -F /etc/hostname"
;;
coreos|openbmc-phosphor)
@ -95,7 +95,7 @@ in
suse)
# We write into /etc/HOSTNAME for backwards-compatibility. Modern SuSE
# has hostnamectl anyway and symlinks /etc/HOSTNAME to /etc/hostname.
echo "printf '%s\\n' '$name_should' > /etc/HOSTNAME"
echo "echo '$name_should' >/etc/HOSTNAME"
echo 'hostname -F /etc/HOSTNAME'
;;
centos|fedora|freebsd|netbsd|openbsd|redhat|scientific)

View File

@ -47,7 +47,7 @@ else
esac
fi
if test -n "${max_len}" -a "$(printf "${name_should}" | wc -c)" -gt "${max_len}"
if test -n "${max_len}" -a "$(printf '%s' "${name_should}" | wc -c)" -gt "${max_len}"
then
printf "Host name too long. Up to %u characters allowed.\n" "${max_len}" >&2
exit 1