[BUG] Bug: "Bad substitution" crash on `!` character in code/responses (Windows)
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?
Bug: "Bad substitution" crash on ! character in code/responses
Environment
- Claude Code version: 2.1.7
- VS Code version: 2.1.7
- OS: Windows 11
- Shell: Git Bash (C:\Program Files\Git\bin\bash.exe)
Description
Claude Code crashes with "Bad substitution" error whenever it encounters a ! character in project code or AI-generated responses. This appears to be caused by bash history expansion (!command) being incorrectly triggered by the internal parser.
Steps to Reproduce
- Open any project containing JavaScript/TypeScript code with
!operators (e.g.,!isEnabled,!card.enabled,!==) - Start a conversation in Claude Code
- Claude Code crashes when processing the code or generating a response containing
!
Error Log
2026-01-15T09:18:38.582Z [ERROR] "Error: Error: Bad substitution: card.enabled
at F (B:/~BUN/root/claude.exe:76:2562)
at <anonymous> (B:/~BUN/root/claude.exe:76:3213)
at map (native:1:11)
at QRf (B:/~BUN/root/claude.exe:76:2302)
at <anonymous> (B:/~BUN/root/claude.exe:76:3367)
at dW (B:/~BUN/root/claude.exe:76:3817)
at jRH (B:/~BUN/root/claude.exe:4314:1755)
at u4 (B:/~BUN/root/claude.exe:4320:195)
at i7$ (B:/~BUN/root/claude.exe:4320:1714)
at isReadOnly (B:/~BUN/root/claude.exe:2894:1961)"
Also crashes on:
[ERROR] "Error: Error: Bad substitution: !isEnabled
Expected Behavior
Claude Code should handle ! characters in code without crashing. The bash history expansion should be disabled or properly escaped in the internal parser.
Additional Context
- The crash occurs even with a clean
settings.local.json(no problematic allowed commands) - Disabling bash history expansion (
set +Hin.bashrc) does not fix the issue - The bug makes Claude Code unusable for any project containing negation operators or
!==comparisons
Workaround
Currently no workaround available. Downgrading to an earlier version may help.
What Should Happen?
Claude Code should handle ! characters in code without crashing. The bash history expansion should be disabled or properly escaped in the internal parser.
Additional Context
The crash occurs even with a clean settings.local.json (no problematic allowed commands)
Disabling bash history expansion (set +H in .bashrc) does not fix the issue
The bug makes Claude Code unusable for any project containing negation operators or !== comparisons
Error Messages/Logs
2026-01-15T09:18:38.582Z [ERROR] "Error: Error: Bad substitution: card.enabled
at F (B:/~BUN/root/claude.exe:76:2562)
at <anonymous> (B:/~BUN/root/claude.exe:76:3213)
at map (native:1:11)
at QRf (B:/~BUN/root/claude.exe:76:2302)
at <anonymous> (B:/~BUN/root/claude.exe:76:3367)
at dW (B:/~BUN/root/claude.exe:76:3817)
at jRH (B:/~BUN/root/claude.exe:4314:1755)
at u4 (B:/~BUN/root/claude.exe:4320:195)
at i7$ (B:/~BUN/root/claude.exe:4320:1714)
at isReadOnly (B:/~BUN/root/claude.exe:2894:1961)"
Steps to Reproduce
Open any project containing JavaScript/TypeScript code with ! operators (e.g., !isEnabled, !card.enabled, !==)
Start a conversation in Claude Code
Claude Code crashes when processing the code or generating a response containing !
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.6
Claude Code Version
2.1.7
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗