Shell snapshot parser corrupts bash options on Windows/Cygwin (or, heckhash)

Resolved 💬 4 comments Opened Jan 11, 2026 by xstaudi Closed Jan 15, 2026

Bug Description

On Windows with Git Bash/Cygwin, Claude Code's shell snapshot mechanism incorrectly parses bash options, resulting in corrupted snapshot files that cause all Bash tool calls to fail with exit code 1.

Environment

  • Claude Code Version: 2.1.4
  • OS: Windows 10/11
  • Shell: GNU bash 5.3.9(1)-release (x86_64-pc-cygwin)
  • Terminal: Git Bash / Cygwin

Symptoms

Every Bash tool call fails with:

/c/Users/.../.claude/shell-snapshots/snapshot-bash-XXXXX.sh: line 3: or: command not found
/c/Users/.../.claude/shell-snapshots/snapshot-bash-XXXXX.sh: line 5: heckhash: command not found
stdin is not a tty

Root Cause

The shell snapshot file contains corrupted bash options:

# Line 3 - should be "set -o monitor" but parsed as:
or

# Line 5 - should be "shopt -u checkhash" but parsed as:
heckhash

It appears the snapshot generator incorrectly parses the output of set -o and shopt commands, splitting words incorrectly:

  • set -o monitor -> extracts only "or"
  • shopt -u checkhash -> loses the leading "c", becomes "heckhash"

Actual Snapshot Content (Lines 1-10)

alias -- ll='ls -l'
alias -- ls='ls -F --color=auto --show-control-chars'
or
set -o onecmd
heckhash
shopt -u checkjobs
shopt -s checkwinsize
...

Expected Behavior

Snapshot should contain valid bash commands that don't fail when sourced.

Workaround

Using PowerShell instead of Bash works:

powershell -Command "node scripts/my-script.js"

Steps to Reproduce

  1. Use Claude Code 2.1.4 on Windows with Git Bash/Cygwin
  2. Run any Bash command (e.g., node --version)
  3. Observe the error messages from the snapshot file

Impact

  • All Bash tool calls fail
  • Cannot use Claude Code's Bash integration on Windows/Cygwin
  • Deleting snapshots doesn't help as they are regenerated with the same corruption

Suggested Fix

Add error handling to the snapshot generator that:

  1. Validates each line is a valid bash command before writing
  2. Uses || true suffix for set -o and shopt commands to prevent failures
  3. Or skips persisting bash options that are environment-specific

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗