Skip to content

fix: gstack-slug bash compatibility — source to eval#354

Merged
garrytan merged 3 commits intomainfrom
garrytan/fix-slug-bash-compat
Mar 23, 2026
Merged

fix: gstack-slug bash compatibility — source to eval#354
garrytan merged 3 commits intomainfrom
garrytan/fix-slug-bash-compat

Conversation

@garrytan
Copy link
Owner

Summary

  • gstack-review-read and gstack-review-log crash with SLUG: unbound variable when run under bash with set -euo pipefail
  • Root cause: source <(gstack-slug) process substitution doesn't reliably set variables in the caller's scope under bash — variables stay empty, and -u (nounset) kills the script
  • Fix: replace source <(gstack-slug) with eval "$(gstack-slug)" everywhere — works in both bash and zsh
  • Updated all 15 .tmpl templates, the gen-skill-docs.ts generator (new SLUG_EVAL and SLUG_SETUP resolvers), and regenerated all SKILL.md files
  • Added 2 regression tests: bash strict-mode verification + relapse guard against source <(.*gstack-slug patterns

Test Coverage

  • All 387+ tests pass (exit code 0)
  • New regression test verifies eval "$(gstack-slug)" sets SLUG and BRANCH under bash -euo pipefail
  • New relapse guard greps all .tmpl and gstack-review-* files to prevent source <(.*gstack-slug from reappearing

Pre-Landing Review

No issues found — mechanical text replacement across templates and bin scripts.

Test plan

  • All tests pass (bun test, exit 0)
  • bash -c 'set -euo pipefail; eval "$(./bin/gstack-slug)"' succeeds
  • gstack-review-read returns JSONL instead of crashing
  • bun run gen:skill-docs regenerates cleanly

🤖 Generated with Claude Code

garrytan and others added 3 commits March 22, 2026 20:57
Under bash with set -euo pipefail, source <(cmd) process substitution
doesn't reliably set variables in the caller's scope. The variables
stay empty and -u (nounset) crashes the script. eval "$(cmd)" works
correctly in both bash and zsh.

Fixes: gstack-review-read, gstack-review-log, gstack-slug comment,
gen-skill-docs.ts resolver functions, and regression tests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge brought in v0.11.4.0 (Codex in Office Hours). Bumped our
bash-compat fix to v0.11.5.0 to avoid version collision.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@garrytan garrytan merged commit fdd4518 into main Mar 23, 2026
zehua added a commit to zehua/gstack that referenced this pull request Mar 23, 2026
Merges origin/main which includes PR garrytan#354 (eval "$()" fix for bash
compat under set -euo pipefail. Resolves conflicts by combining:

- Upstream's eval  form for all gstack-slug / gstack-diff-scope calls
- Our /Users/zehua/.claude-personal dynamic path support
- Upstream's {{SLUG_EVAL}}/{{SLUG_SETUP}} template placeholders in .tmpl files

All SKILL.md files regenerated. bun test passes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EOF
)
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