[BUG] Bash tool fails with syntax error when multiple command substitutions $(...) are used
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 incorrectly escapes command substitutions when there are multiple $(...) in a single tool call, causing syntax errors. The tool converts $(...) to \$ ( ... ) which breaks bash syntax.
What Should Happen?
The command should execute normally, as it does in a regular bash terminal.
Environment:
- Platform: Linux
- OS: Linux 6.12.57+deb13-amd64
- Claude Code version: [your version]
Workaround:
Use only ONE command substitution per Bash tool call:
# Works - single substitution
TOKEN=$(cat some/file)
echo "Token: $TOKEN"
Or use inline substitution in a single command:
curl https://example.com -H "Auth: $(cat token/file)"
Error Messages/Logs
Error:
/bin/bash: eval: line 1: syntax error near unexpected token `('
/bin/bash: eval: line 1: `TOKEN=\$ ( cat some/file ) PORT\=\$ ( grep pattern file < /dev/null | cut -f2 ) echo 'Token: ' echo 'Port: ''
Notice the command substitutions are incorrectly escaped as \$ ( ... ).
Steps to Reproduce
- Use the Bash tool with multiple command substitutions:
TOKEN=$(cat some/file)
PORT=$(grep pattern file | cut -f2)
echo "Token: $TOKEN"
echo "Port: $PORT"
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.55 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗