Bash tool misleadingly executes in user's default shell instead of actual bash
Resolved 💬 6 comments Opened Jun 22, 2025 by ashebanow Closed Aug 21, 2025
Description:
Summary
The "Bash" tool in Claude Code claims to execute bash commands but actually runs commands in the user's default shell environment, triggering
shell initialization files and potentially causing unexpected behavior.
Expected Behavior
When using the "Bash" tool, commands should either:
- Execute in an isolated bash environment (bash -c "command"), or
- The tool should be renamed/described accurately (e.g., "Shell" tool)
Actual Behavior
- Tool is named "Bash" and descriptions reference "bash commands"
- Commands actually execute in user's default shell (zsh in this case)
- Shell initialization files like .zshenv are sourced during execution
- This can cause errors unrelated to the intended command
Steps to Reproduce
- Set zsh as default shell on macOS
- Add problematic content to .zshenv (e.g., ---@type zsh)
- Use Claude Code's "Bash" tool to run any command
- Observe that .zshenv gets executed and produces errors
Evidence
⏺ Bash(rm /path/to/file)
⎿ /Users/user/.zshenv:1: command not found: ---@type
The error shows .zshenv was executed despite claiming to use bash.
Environment
- Platform: macOS
- Default shell: zsh
- Claude Code version: [current]
Suggested Fix
Either:
- Execute commands with bash -c "command" for true bash isolation
- Rename tool to "Shell" and update descriptions to be accurate
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗