From 4775d6883083aec814ae899a283c74f9db144aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 11 Sep 2020 09:52:43 +0200 Subject: [PATCH] fix returncodes, make debug --- functions.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/functions.sh b/functions.sh index 2ec22b5..fe9e169 100755 --- a/functions.sh +++ b/functions.sh @@ -618,12 +618,13 @@ reachable () { fi local PORT=${2:-22} local SEC=${3:-1} - local res=999999 + local res=999 local i - echo -n "Try to connect to ${SERVER}(${IP}):${PORT} " >&2 + $MYSHELLCONFIG_DEBUG && echo -n "Try to connect to ${SERVER}(${IP}):${PORT} " >&2 for i in $(seq 1 $SEC); do - echo -n "." >&2 + $MYSHELLCONFIG_DEBUG && echo -n "." >&2 if reachable-default ${IP} ${PORT} 2>/dev/null; then + res=0 break else res=$? @@ -631,7 +632,9 @@ reachable () { [ ${SEC} -gt 1 -a $i -lt ${SEC} ] && sleep 1 done - [ ${res} -gt 0 ] && echo " not reachable" >&2 || echo " success" >&2 + if $MYSHELLCONFIG_DEBUG ; then + [ ${res} -gt 0 ] && echo " not reachable" >&2 || echo " success" >&2; + fi return $res