From 3f3efab221ff63a9f44db01720434db38b0a6b81 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Mar 2022 07:22:59 +0530 Subject: [PATCH] Fix hostname detection when hostname binary not present --- shell-integration/ssh/bootstrap.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shell-integration/ssh/bootstrap.sh b/shell-integration/ssh/bootstrap.sh index 2d6c07fc7..d25bb0940 100644 --- a/shell-integration/ssh/bootstrap.sh +++ b/shell-integration/ssh/bootstrap.sh @@ -18,8 +18,13 @@ trap 'cleanup_on_bootstrap_exit' EXIT data_started="n" data_complete="n" if [ -z "$HOSTNAME" ]; then - hostname=$(hostname) - if [ -z "$hostname" ]; then hostname="_"; fi + hostname=$(hostname 2> /dev/null) + if [ -z "$hostname" ]; then + hostname=$(hostnamectl hostname 2> /dev/null) + if [ -z "$hostname" ]; then + hostname="_"; + fi + fi else hostname="$HOSTNAME" fi