[BUG] Bash tool fails with exit 127 when shell snapshot replays extglob syntax in non-interactive bash 5

Resolved 💬 1 comment Opened May 26, 2026 by suetranter Closed Jun 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The shell snapshot replayer fails to parse extglob syntax in captured function bodies when run in non-interactive
bash 5, causing the bash tool to exit with code 127.

What Should Happen?

The bash tool should execute commands successfully. The snapshot replayer should handle bash functions that use
extglob syntax — common in bash-completion modules and other shell environments where extglob is on by default in
interactive bash.

Error Messages/Logs

The wrapper command is constructed like:
  source SNAPSHOT 2>/dev/null || true && { shopt -u extglob ...; } && eval '<actual command>'
  The 2>/dev/null swallows the parse error. The function (e.g. get_modules from bash-completion v1's cvs module) is
  never defined, so the actual command fails with exit 127.

  bash -x trace narrows the parse failure to the !(CVSROOT) extglob syntax in bash-completion v1's cvs module — fails
  to parse because extglob defaults off in non-interactive bash 5.

Steps to Reproduce

  1. macOS, bash 5
  2. brew install bash-completion (v1 — note: v2 doesn't have this issue)
  3. Start Claude Code
  4. Any bash tool call fails with exit 127

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.136 - @anthropic-ai/claude-code

Platform

Other

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

Root cause

Two pieces both miss the fix:

  1. Snapshot capture should shopt -s extglob before emitting function definitions.
  2. The source-wrapper command should shopt -s extglob before the source, not unset it after.

## Workaround

brew uninstall bash-completion && brew install bash-completion@2 — v2 is the supported package on bash 4+/5 and
doesn't use the problematic syntax. Or add shopt -s extglob to the user's shell rc.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗