From 41249966740c33a591b9dcc14edc37ddaa595bb6 Mon Sep 17 00:00:00 2001 From: Moviuro Date: Thu, 28 May 2020 11:25:20 +0200 Subject: [PATCH] zshenv, zshrc: add fallback to uname for HOSTNAME uname -n is POSIX, and should work when neither hostname(1) nor hostnamectl(1) exist. Enhances #97 --- etc/zsh/zshenv | 2 ++ etc/zsh/zshrc | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/etc/zsh/zshenv b/etc/zsh/zshenv index 9b70921..8e4ae78 100644 --- a/etc/zsh/zshenv +++ b/etc/zsh/zshenv @@ -32,6 +32,8 @@ elif [[ -x $(which hostname) ]] ; then export HOSTNAME="$(hostname)" elif [[ -x $(which hostnamectl) ]] ; then export HOSTNAME="$(hostnamectl --static)" +else + export HOSTNAME="$(uname -n)" fi # make sure /usr/bin/id is available diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 43cda0c..6360f5f 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -843,6 +843,8 @@ function grmlcomp () { localname=$(hostname) elif check_com hostnamectl ; then localname=$(hostnamectl --static) + else + localname="$(uname -n)" fi hosts=( @@ -2522,6 +2524,8 @@ function grml_maintain_name () { localname=$(hostname) elif check_com hostnamectl ; then localname=$(hostnamectl --static) + else + localname="$(uname -n)" fi # set hostname if not running on local machine -- 2.1.4