Skip to content

fix(preamble): make .pending-* glob pattern zsh-compatible (fixes #313)#332

Open
hnshah wants to merge 1 commit intogarrytan:mainfrom
hnshah:fix/zsh-glob-pending-files-issue-313
Open

fix(preamble): make .pending-* glob pattern zsh-compatible (fixes #313)#332
hnshah wants to merge 1 commit intogarrytan:mainfrom
hnshah:fix/zsh-glob-pending-files-issue-313

Conversation

@hnshah
Copy link

@hnshah hnshah commented Mar 22, 2026

Problem

When running gstack skills in zsh, users see this error:

(eval):22: no matches found: /Users/.../.gstack/analytics/.pending-*

This breaks all gstack skills for zsh users (macOS default shell).

Root Cause

The Preamble code in scripts/gen-skill-docs.ts line 167 contains:

for _PF in ~/.gstack/analytics/.pending-*; do ...

In zsh, glob patterns that don't match any files cause an error:

zsh: no matches found: pattern

In bash, the loop simply iterates zero times.

Since .pending-* files rarely exist (they're temporary), this breaks all skills for zsh users on every run.

Solution

Check if any .pending-* files exist before attempting the for loop:

# zsh-compatible: check if .pending-* files exist before looping
[ -n "$(ls ~/.gstack/analytics/.pending-* 2>/dev/null)" ] && for _PF in ~/.gstack/analytics/.pending-*; do ...

This approach:

  • ✅ Works in both bash and zsh
  • ✅ Silently skips the loop when no pending files exist (normal case)
  • ✅ Executes the loop when pending files are present
  • ✅ Uses ls with error suppression (2>/dev/null) for portability

Testing

No pending files: loop skipped, no error
Pending files exist: loop runs normally
bash compatibility: works as before
zsh compatibility: no "no matches found" error
TypeScript syntax check: passes

Impact

  • Fixes all gstack skills for zsh users (macOS default)
  • No behavior change for bash users
  • Minimal change (1 line modified)
  • Zero performance impact

Environment Tested

  • macOS with zsh (default shell)
  • No .pending-* files present (normal case)
  • Skills now run without glob errors

Fixes #313

…rytan#313)

**Problem:**
When running gstack skills in zsh, users see this error:
  (eval):22: no matches found: /Users/.../.gstack/analytics/.pending-*

**Root Cause:**
The Preamble code in gen-skill-docs.ts (line 167) contains:
  for _PF in ~/.gstack/analytics/.pending-*; do ...

In zsh, glob patterns that don't match any files cause an error:
  'no matches found: pattern'

In bash, the loop simply iterates zero times. This breaks all gstack
skills for zsh users (common on macOS).

**Solution:**
Check if any .pending-* files exist BEFORE attempting the for loop:
  [ -n "$(ls ~/.gstack/analytics/.pending-* 2>/dev/null)" ] && for ...

This approach:
- ✅ Works in both bash and zsh
- ✅ Silently skips the loop when no pending files exist (normal case)
- ✅ Executes the loop when pending files are present
- ✅ Uses ls with error suppression (2>/dev/null) for portability

**Testing:**
- ✅ No pending files: loop skipped, no error
- ✅ Pending files exist: loop runs normally
- ✅ Compatible with bash and zsh
- ✅ TypeScript syntax check passes

**Impact:**
Fixes all gstack skills for zsh users (macOS default shell).

Fixes garrytan#313
@hnshah hnshah force-pushed the fix/zsh-glob-pending-files-issue-313 branch from d3300d4 to 734d30a Compare March 23, 2026 03:28
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.

zsh glob error: 'no matches found' for .pending-* pattern

1 participant