aboutsummaryrefslogtreecommitdiffstats
path: root/mcp/scripts/lib.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mcp/scripts/lib.sh')
-rw-r--r--mcp/scripts/lib.sh25
1 files changed, 14 insertions, 11 deletions
diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh
index da129a7da..a165bb367 100644
--- a/mcp/scripts/lib.sh
+++ b/mcp/scripts/lib.sh
@@ -191,15 +191,18 @@ function parse_yaml {
}
function wait_for {
- local total_attempts=$1; shift
- local cmdstr=$*
- local sleep_time=10
- echo "[NOTE] Waiting for cmd to return success: ${cmdstr}"
- # shellcheck disable=SC2034
- for attempt in $(seq "${total_attempts}"); do
- # shellcheck disable=SC2015
- eval "${cmdstr}" && return 0 || true
- echo -n '.'; sleep "${sleep_time}"
- done
- return 1
+ # Execute in a subshell to prevent local variable override during recursion
+ (
+ local total_attempts=$1; shift
+ local cmdstr=$*
+ local sleep_time=10
+ echo "[NOTE] Waiting for cmd to return success: ${cmdstr}"
+ # shellcheck disable=SC2034
+ for attempt in $(seq "${total_attempts}"); do
+ # shellcheck disable=SC2015
+ eval "${cmdstr}" && return 0 || true
+ echo -n '.'; sleep "${sleep_time}"
+ done
+ return 1
+ )
}