From 8f5ae3af7470d10308cf1b29341c02d373dc7da1 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Wed, 1 Jul 2026 20:01:49 +0000 Subject: [PATCH] Fix deploy_service set -e exit swallowing errors in command substitution Using 'if ! pct exec ... > tmp 2>&1' avoids the bash set -e + $() interaction where the shell exits inside the subshell before || fires. Errors are now captured to a temp file and printed via msg_error. Co-Authored-By: Claude Sonnet 4.6 --- install-stack.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/install-stack.sh b/install-stack.sh index e60f61c..efb21d8 100755 --- a/install-stack.sh +++ b/install-stack.sh @@ -480,17 +480,21 @@ deploy_service() { local id=$1 repo_name=$2 local_src=$3 dest=$4 if [[ "$USE_FORGEJO" == "true" ]]; then local url; url=$(build_clone_url "$repo_name") - local out - out=$(pct exec "$id" -- bash -c " + local tmp; tmp=$(mktemp /tmp/hotel-manage-deploy-out-XXXX) + if ! pct exec "$id" -- bash -c " if [ -d '${dest}/.git' ]; then - cd '${dest}' && git pull 2>&1 + cd '${dest}' && git pull else - git clone '${url}' '${dest}' 2>&1 + git clone '${url}' '${dest}' fi - " 2>&1) || msg_error "Deploy of ${repo_name} to LXC ${id} failed: + " > "$tmp" 2>&1; then + local out; out=$(cat "$tmp"); rm -f "$tmp" + msg_error "Deploy of ${repo_name} to LXC ${id} failed: ${out} - Debug: pct enter ${id} && git clone ${url//oauth2:*@/} /tmp/test-clone" + Debug: pct enter ${id} && git clone ${FORGEJO_BASE}/${repo_name}.git /tmp/test-clone" + fi + rm -f "$tmp" else push_dir "$id" "$local_src" "$dest" fi