fix(installers): correct exit status on macOS bash 3.2 - #24
Open
gorakhnathy7 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One-line fix in
ai/lib/common.sh: capture$?at the top of thecleanup_on_exitEXIT 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_exitends with a[ -f ... ] && rmtest that legitimately fails whenTEMP_FILESis empty — so every installer inai/exits 1 on macOS even on success (codex,claude-code, all of them). Anyset -ewrapper, Makefile, or CI step checking thecurl | bashexit 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-runandclaude-code install.sh --helpboth exit 1; after, both exit 0, and real validation failures still exit 1 (checked with the github-copilot installer's token-validation error path).