aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-19 11:53:13 -0500
committerCraig Jennings <c@cjennings.net>2026-05-19 11:53:13 -0500
commit3d1a88fa002942c5d5376250b705a6dd8252ab2e (patch)
tree12e0ef0b377ff4cf43df90756f1f53a833df482f
parent6a96f03e419d4c17ffc920221a34d6210df47a6d (diff)
downloadarchsetup-3d1a88fa002942c5d5376250b705a6dd8252ab2e.tar.gz
archsetup-3d1a88fa002942c5d5376250b705a6dd8252ab2e.zip
fix(archsetup): log the real exit code from failed installs
`retry_install` was logging "error code: 0" for every retry-exhausted install (6 AUR packages on the 2026-05-16 run, 2 on the 2026-05-18 run). Root cause: `last_exit_code=$?` ran AFTER an `if eval ...; then return 0; fi` block. Bash defines an if-compound's exit status as zero when no condition tested true. With no else clause and a failing eval, that's exactly what happens, so `$?` captures 0 instead of eval's actual exit code. Now eval runs unconditionally, `$?` lands in `last_exit_code` right after it, and the if just compares against the captured value. Same control flow, accurate codes in the summary. Verified with a small bash test: the old pattern reports `$?=0` after a failing if, the new pattern reports the real exit.
-rwxr-xr-xarchsetup9
1 files changed, 7 insertions, 2 deletions
diff --git a/archsetup b/archsetup
index d044d1c..6c17232 100755
--- a/archsetup
+++ b/archsetup
@@ -493,10 +493,15 @@ retry_install() {
display "task" "installing $pkg via $source"
while [ $attempt -le $MAX_INSTALL_RETRIES ]; do
- if eval "$cmd" >> "$logfile" 2>&1; then
+ # Capture $? from eval directly. A naked `last_exit_code=$?` after
+ # `if eval; then ...; fi` reads the if-compound's exit status, which
+ # bash defines as 0 when no condition tested true — so a failing
+ # eval gets logged as "error code: 0" downstream.
+ eval "$cmd" >> "$logfile" 2>&1
+ last_exit_code=$?
+ if [ $last_exit_code -eq 0 ]; then
return 0
fi
- last_exit_code=$?
attempt=$((attempt + 1))
if [ $attempt -le $MAX_INSTALL_RETRIES ]; then
display "task" "retrying $pkg (attempt $attempt/$MAX_INSTALL_RETRIES)"