[__hostname] Fix "command not found" errors with old Bash

This commit is contained in:
Dennis Camera 2019-10-25 01:40:48 +02:00
parent c3b066c147
commit 629d443f5a
3 changed files with 5 additions and 5 deletions

View File

@ -21,4 +21,4 @@
# Check whether system has hostnamectl
#
command -v hostnamectl || true
command -v hostnamectl 2>/dev/null || true

View File

@ -2,7 +2,7 @@
command -v getconf >/dev/null || exit 0
val=$(getconf HOST_NAME_MAX 2>/dev/null)
val=$(getconf HOST_NAME_MAX 2>/dev/null) || exit 0
if test -n "${val}" -a "${val}" != 'undefined'
then

View File

@ -22,7 +22,7 @@
#
# Firstly, check hostnamectl if available.
if command -v hostnamectl >/dev/null
if command -v hostnamectl >/dev/null 2>&1
then
hostnamectl status --static && exit 0
fi
@ -32,10 +32,10 @@ fi
case $("$__explorer/os")
in
alpine|archlinux|coreos|debian|devuan|ubuntu)
[ -f /etc/hostname ] && cat /etc/hostname
test -f /etc/hostname && cat /etc/hostname
;;
centos|fedora|redhat|scientific)
[ -f /etc/sysconfig/network ] \
test -f /etc/sysconfig/network \
&& (. /etc/sysconfig/network && echo "$HOSTNAME")
;;
freebsd)