Skip to content

fix(installers): correct exit status on macOS bash 3.2 - #24

Open
gorakhnathy7 wants to merge 1 commit into
mainfrom
fix/installer-exit-codes
Open

fix(installers): correct exit status on macOS bash 3.2#24
gorakhnathy7 wants to merge 1 commit into
mainfrom
fix/installer-exit-codes

Conversation

@gorakhnathy7

Copy link
Copy Markdown
Contributor

What

One-line fix in ai/lib/common.sh: capture $? at the top of the cleanup_on_exit EXIT trap and re-exit with it.

Why

On macOS /bin/bash (3.2), the exit status of the last command in an EXIT trap silently becomes the script's exit status. cleanup_on_exit ends with a [ -f ... ] && rm test that legitimately fails when TEMP_FILES is empty — so every installer in ai/ exits 1 on macOS even on success (codex, claude-code, all of them). Any set -e wrapper, Makefile, or CI step checking the curl | bash exit code sees failure on a successful install. Linux bash 4/5 preserves the original status, which is why this went unnoticed.

Verified

On macOS bash 3.2.57: before the fix, codex install.sh --dry-run and claude-code install.sh --help both exit 1; after, both exit 0, and real validation failures still exit 1 (checked with the github-copilot installer's token-validation error path).

On macOS /bin/bash (3.2), the exit status of the last command in an EXIT
trap becomes the script's exit status. cleanup_on_exit ends with a
'[ -f ... ] && rm' test that legitimately fails when TEMP_FILES is empty,
so every installer exited 1 even on success — breaking any set -e wrapper
or CI that checks the curl|bash exit code. Linux bash 4/5 preserves the
original status, which is why this went unnoticed.

Capture $? on trap entry and re-exit with it, preserving both success (0)
and real failure codes. Verified on macOS bash 3.2 across the codex,
claude-code, and github-copilot installers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant