From 27e2d040ed018c8c224365ea2be96da8b15ac6f3 Mon Sep 17 00:00:00 2001 From: Evgeny Sinelnikov Date: Fri, 8 Apr 2022 11:44:05 +0400 Subject: [PATCH] Add error handling to test_hostnamectl --- ddiag.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ddiag.sh b/ddiag.sh index 2bae795..935edfb 100644 --- a/ddiag.sh +++ b/ddiag.sh @@ -94,10 +94,12 @@ run() check_hostnamectl() { - local static_host="$(hostnamectl --static)" - local transient_host="$(hostname)" - _command hostnamectl - test "$static_host" = "$transient_host" + local retval=0 + local static_host="$(hostnamectl --static)" || retval=1 + local transient_host="$(hostname)" || retval=1 + _command hostnamectl || retval=1 + test "$static_host" = "$transient_host" || retval=1 + return $retval } test_hostname()