Repository navigation
Description
Repo: gstack 1.67.1.0 · File: ~/.claude/skills/gstack/codex/SKILL.md · Env: codex-cli 0.149.0, zsh 5.9, macOS 26.5.2 arm64
${PIPESTATUS[0]} is a bash array idiom. zsh has $pipestatus, lowercase and 1-indexed, and does not populate PIPESTATUS. Under zsh the expansion yields an empty string:
$ bash -c 'false | true; echo "[${PIPESTATUS[0]}]"'
[1]
$ zsh -c 'false | true; echo "[${PIPESTATUS[0]}]"'
[]
$ zsh -c 'false | true; echo "[${pipestatus[1]}]"'
[1]
The codex skill uses it at three sites, all on codex exec … --json | python pipelines:
SKILL.md:1410— challengeSKILL.md:1567— consult (new session)SKILL.md:1595— consult (resume)
_CODEX_EXIT=${PIPESTATUS[0]}
# Fix 1: hang detection — log + surface actionable message
if [ "$_CODEX_EXIT" = "124" ]; then
_gstack_codex_log_event "codex_timeout" "600"
_gstack_codex_log_hang "challenge" ...
echo "Codex stalled past 10 minutes. ..."
elif [ "$_CODEX_EXIT" != "0" ]; then
# Surface non-zero exits so the calling agent doesn't read "no output" as
# a silent model/API stall. See #1327.
echo "[codex exit $_CODEX_EXIT] $(head -1 "$TMPERR" ...)"
head -20 "$TMPERR" ...
_gstack_codex_log_event "codex_nonzero_exit" "challenge:$_CODEX_EXIT"
fiEffect
With _CODEX_EXIT empty, both branches misfire — reproduced directly:
$ zsh -c '_CODEX_EXIT=""
if [ "$_CODEX_EXIT" = "124" ]; then echo "hang-detection branch"
elif [ "$_CODEX_EXIT" != "0" ]; then echo "NON-ZERO/error branch"
else echo "success branch"; fi'
NON-ZERO/error branch
- Hang detection never fires.
[ "" = "124" ]is false, so on a genuine 600s timeout the user gets no "Codex stalled past 10 minutes" message and neithercodex_timeoutnorlog_hangtelemetry is written. The exit-124 path is unreachable on zsh. - Every run reports a spurious failure.
[ "" != "0" ]is true, so successful runs take the error branch: they print[codex exit ]with a blank code, dump up to 20 lines of stderr, and log a falsecodex_nonzero_exitevent.
So on zsh both of the protections these blocks exist for — the hang detection, and the #1327 fix for surfacing real non-zero exits — are inoperative, and the second one inverts into noise on every clean run.
Two qualifications, in fairness:
- The review path is unaffected.
/codex reviewat:1058uses a bare_CODEX_EXIT=$?with no pipeline, which is correct in both shells. The fail-closed gate added since Two stated guarantees in thecodexskill don't hold (v1.60.1.0) #2524 gets a real value. This report is only about the three piped sites. - The direction is conservative — a spurious failure, never a spurious pass. It is a correctness and noise problem, not a safety hole. Telemetry counts of
codex_nonzero_exitfrom zsh users will be inflated, andcodex_timeoutunder-reported, which may be worth knowing if those feed any dashboard.
zsh is the default login shell on macOS, and Claude Code's Bash tool inherits it ($0=/bin/zsh, BASH_VERSION unset here), so this is the default path on macOS rather than an edge case.
Suggested fix
Portable one-liner, verified in both shells (success and failure):
_CODEX_EXIT=${PIPESTATUS[0]:-${pipestatus[1]}}bash: failing → [7] success → [0]
zsh: failing → [7] success → [0]
bash populates PIPESTATUS[0], so the default never evaluates; zsh leaves it empty and falls through to pipestatus[1]. Alternatively, drop the pipeline — redirect codex's --json output to a temp file and run the Python parser over the file, which makes a bare $? correct and matches what the review path already does.
Related: #2524 (both items fixed — thank you), and #1798, a different zsh-vs-bash assumption in setup-gbrain.
Activity
v1.78.0.0 fix: the two-red-lanes wave — AUQ collapse rooted, OSV gree…