fix(deploy): run_quiet works on bash 3.2 — drop subshell, toggle set -e around wait
- Background subshell '( cmd ) &' + 'wait' interacted badly with set -euo pipefail on macOS bash 3.2, killing the script silently before the progress-bar's error branch could run - New approach: just 'cmd &' (no subshell), bracket the whole bg+wait region with 'set +e' / 'set -e', then check rc explicitly - Also adds ERR-trap with call stack + RUN_QUIET_DEBUG=1 fallback (streams output directly via tee, useful for debugging build failures)
This commit is contained in:
parent
9f8e99d287
commit
24a52a5bae
@ -51,6 +51,9 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ERR-Trap: zeigt die exakte Zeile + Command der set -e ausgelöst hat
|
||||||
|
trap 'rc=$?; echo "" >&2; echo "✗ deploy.sh aborted (rc=$rc)" >&2; echo " line $LINENO: $BASH_COMMAND" >&2; echo " call stack:" >&2; for ((i=0;i<${#FUNCNAME[@]};i++)); do echo " #$i ${FUNCNAME[$i]:-main} (${BASH_SOURCE[$i]}:${BASH_LINENO[$i]})" >&2; done' ERR
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
APP_CONFIG="$SCRIPT_DIR/app.config.ts"
|
APP_CONFIG="$SCRIPT_DIR/app.config.ts"
|
||||||
PACKAGE_JSON="$SCRIPT_DIR/package.json"
|
PACKAGE_JSON="$SCRIPT_DIR/package.json"
|
||||||
@ -168,17 +171,30 @@ run_quiet() {
|
|||||||
echo "${YELLOW}[DRY-RUN]${RESET} $label: $*"
|
echo "${YELLOW}[DRY-RUN]${RESET} $label: $*"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if $VERBOSE || [[ ! -t 1 ]]; then
|
# Debug / verbose mode: stream output directly via tee (no subshell, no spinner)
|
||||||
|
if $VERBOSE || [[ "${RUN_QUIET_DEBUG:-0}" = "1" ]] || [[ ! -t 1 ]]; then
|
||||||
log "$label"
|
log "$label"
|
||||||
|
set +e
|
||||||
"$@" 2>&1 | tee "$logfile"
|
"$@" 2>&1 | tee "$logfile"
|
||||||
return ${PIPESTATUS[0]}
|
local prc=${PIPESTATUS[0]}
|
||||||
|
set -e
|
||||||
|
if [[ $prc -eq 0 ]]; then
|
||||||
|
ok "$label"
|
||||||
|
else
|
||||||
|
error "$label fehlgeschlagen (exit $prc) — voller Log: $logfile"
|
||||||
|
exit $prc
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
local start=$SECONDS
|
local start=$SECONDS
|
||||||
local expected pid elapsed subtitle rc
|
local expected pid elapsed subtitle rc
|
||||||
expected=$(runtime_lookup "$label" || echo 0)
|
expected=$(runtime_lookup "$label" || echo 0)
|
||||||
expected=${expected:-0}
|
expected=${expected:-0}
|
||||||
RUN_QUIET_I=0
|
RUN_QUIET_I=0
|
||||||
( "$@" >"$logfile" 2>&1 ) &
|
# Disable set -e/pipefail around backgrounding so wait can capture rc cleanly
|
||||||
|
# (bash 3.2 on macOS aborts unexpectedly with the subshell+wait pattern under set -e)
|
||||||
|
set +e
|
||||||
|
"$@" >"$logfile" 2>&1 &
|
||||||
pid=$!
|
pid=$!
|
||||||
while kill -0 "$pid" 2>/dev/null; do
|
while kill -0 "$pid" 2>/dev/null; do
|
||||||
elapsed=$((SECONDS - start))
|
elapsed=$((SECONDS - start))
|
||||||
@ -203,7 +219,9 @@ run_quiet() {
|
|||||||
render_progress "$elapsed" "$expected" "$label" "$subtitle"
|
render_progress "$elapsed" "$expected" "$label" "$subtitle"
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
done
|
done
|
||||||
wait "$pid" && rc=0 || rc=$?
|
wait "$pid"
|
||||||
|
rc=$?
|
||||||
|
set -e
|
||||||
elapsed=$((SECONDS - start))
|
elapsed=$((SECONDS - start))
|
||||||
# Clear progress line
|
# Clear progress line
|
||||||
printf '\r\033[K' >&2
|
printf '\r\033[K' >&2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user