From 2b1957a0a3db7d63c1844abb84223655c30a7eb0 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Fri, 16 Aug 2024 13:42:11 +0800 Subject: [PATCH] home-manager: fix early exit due to FQDN error Since 89670e27e101b9b30f5900fc1eb6530258d316b1, FQDN lookup errors from `hostname -f` may cause an early exit of the whole program. This commit fixes the problem by absorbing the FQDN query inside the `if` statement. --- home-manager/home-manager | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index ab4de5387..8b7bbc76a 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -202,8 +202,7 @@ function setFlakeAttribute() { local hostnameArray=() # FQDN lookup can fail depending on the resolver. local fqdn - fqdn="$(hostname -f 2> /dev/null)" - if [[ $? -eq 0 ]]; then + if fqdn="$(hostname -f 2> /dev/null)"; then hostnameArray+=( "$USER@$fqdn" ) fi # Check FQDN, long, and short hostnames; long first to preserve