From: Alexandru Avadanii Date: Sun, 7 Jan 2018 18:22:18 +0000 (+0100) Subject: lib.sh: Fix stop condition in wait_for X-Git-Tag: opnfv-6.0.0~155 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F59%2F50159%2F2;p=fuel.git lib.sh: Fix stop condition in wait_for Change-Id: Ida693b6dd328db283d6992ac33500f4dd1a73eb8 Signed-off-by: Alexandru Avadanii --- diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh index e9dd30960..aebf97055 100644 --- a/mcp/scripts/lib.sh +++ b/mcp/scripts/lib.sh @@ -437,7 +437,7 @@ function wait_for { local total_attempts=$1; shift local cmdstr=$* local sleep_time=10 - echo "[wait_for] Waiting for cmd to return success: ${cmdstr}" + echo -e "\n[wait_for] Waiting for cmd to return success: ${cmdstr}" # shellcheck disable=SC2034 for attempt in $(seq "${total_attempts}"); do echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}" @@ -445,11 +445,11 @@ function wait_for { # shellcheck disable=SC2015 eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true else - ( eval "${cmdstr}" || echo __fuel_wf_failure__ ) |& tee /dev/stderr | \ - grep -Eq '(Not connected|No response|__fuel_wf_failure__)' || \ - echo "[wait_for] OK: ${cmdstr}" && return 0 + !(eval "${cmdstr}" || echo __fuel_wf_failure__) |& tee /dev/stderr | \ + grep -Eq '(Not connected|No response|__fuel_wf_failure__)' && \ + echo "[wait_for] OK: ${cmdstr}" && return 0 || true fi - echo -n '.'; sleep "${sleep_time}" + sleep "${sleep_time}" done echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}" return 1