Skip to content

systemtwosecurity/claude-bash-fix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

claude-bash-fix

Fixes Claude Code's bash command mangling (affects macOS, Linux, and WSL).

Problem

Claude Code mangles bash commands before execution:

  • $(cmd) becomes \$ ( cmd )
  • Spurious < /dev/null inserted before pipes

This breaks subshell commands like echo $(git rev-parse HEAD).

Related issues:

  • #15599 - $() mangled to \$ ( ) and < /dev/null injected with pipes
  • #7387 - Shell script fails due to escaping ($(find ...)\$ ( find ...)
  • #3839 - < /dev/null inserted inside single-quoted arguments

Solution

A wrapper script that intercepts shell calls and fixes the mangling before passing to real bash.

Install

./install.sh              # Install to ~/bin
./install.sh /usr/local/bin  # Or specify path

Add to your shell profile:

export CLAUDE_CODE_SHELL="$HOME/bin/claude-bash-fix"

Restart Claude Code.

Test

bats tests/wrapper.bats

Debug

DEBUG_CLAUDE_BASH=1 claude  # See wrapper debug output

Why not a PR to Claude Code?

The actual Claude Code implementation is closed-source (in Anthropic's private claude-cli-internal repo). The public github.com/anthropics/claude-code repo only contains plugins and documentation. Report bugs via /bug in Claude Code.

About

Fixes Claude Code's bash command mangling (affects macOS, Linux, and WSL)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages