[BUG] Bash tool still escapes ! with backslash, corrupting CLI arguments

Resolved 💬 2 comments Opened Mar 3, 2026 by gwillem Closed Mar 3, 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 Bash tool inserts a backslash before ! characters, even inside single-quoted strings where no shell expansion should occur. This is the same bug as #2941 (auto-closed by stale bot despite being unfixed) and #24979.

What Should Happen?

! should be passed through literally. Single-quoted strings in both bash and zsh do not expand !.

Error Messages/Logs

Program logs os.Args to a file. When Claude Code runs:

myapp --password='foo%!bar'

Logged args show:

--password=foo%\!bar

The \! corrupts the value, causing authentication failure. Confirmed by writing os.Args to /tmp/debug.log from within the Go program.

Steps to Reproduce

  1. Ask Claude Code to run any Bash command containing ! in an argument
  2. The ! is escaped to \! before reaching the subprocess

Claude Model

Opus

Is this a regression?

No, this has been broken since at least #2941 (July 2025)

Claude Code Version

Latest

Platform

Anthropic API

Operating System

macOS (Darwin 23.3.0)

Terminal/Shell

zsh

Additional Information

Related closed issues: #2941, #24979. Both were auto-closed by a stale bot despite the bug persisting.

View original on GitHub ↗

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