diff --git a/apps/rebreak-native/deploy.sh b/apps/rebreak-native/deploy.sh index 4a64081..3f8884b 100755 --- a/apps/rebreak-native/deploy.sh +++ b/apps/rebreak-native/deploy.sh @@ -51,6 +51,9 @@ 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)" APP_CONFIG="$SCRIPT_DIR/app.config.ts" PACKAGE_JSON="$SCRIPT_DIR/package.json" @@ -168,17 +171,30 @@ run_quiet() { echo "${YELLOW}[DRY-RUN]${RESET} $label: $*" return 0 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" + set +e "$@" 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 local start=$SECONDS local expected pid elapsed subtitle rc expected=$(runtime_lookup "$label" || echo 0) expected=${expected:-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=$! while kill -0 "$pid" 2>/dev/null; do elapsed=$((SECONDS - start)) @@ -203,7 +219,9 @@ run_quiet() { render_progress "$elapsed" "$expected" "$label" "$subtitle" sleep 0.2 done - wait "$pid" && rc=0 || rc=$? + wait "$pid" + rc=$? + set -e elapsed=$((SECONDS - start)) # Clear progress line printf '\r\033[K' >&2