[BUG] Bash tool error reporting insufficient for chained commands (only "Exit code 1")
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?
Problem
While the Bash tool has improved from returning just "Error: Error", it still provides insufficient diagnostic information for failed commands, particularly with complex chained operations. Many failures return only "Exit code 1" with no context about what failed.
## Impact
- Limited diagnostic information: Exit code alone doesn't explain what failed or why
- Inefficient retry loops: Claude must guess at fixes and retry variations
- Wasted resources: Multiple attempts without clear feedback
- Difficult debugging: Users can't determine root causes
What Should Happen?
## Current Behavior vs Desired Behavior
### What we get now:
Error: Exit code 1
### What would be helpful:
Exit code 1
/path/to/script: line 47: cd: gnome: No such file or directory
## Proposed Improvements
- Always capture and return stderr alongside exit codes
- For chained commands, show which command failed (if detectable via set -e or similar)
- Include shell error messages (e.g., "No such file or directory", "Permission denied")
- Consider showing the failing command from the chain
This would enable Claude to make informed corrections instead of blind retries.
Error Messages/Logs
Steps to Reproduce
## Reproduction Examples
### Example 1: Multiple chained cd commands
``bash``
cd /home/lepr/workspace/configs && cd gnome && cd scripts && pwd
Current result: Exit code 1
Problem: No indication of which cd failed or why
### Example 2: Chained cd with script execution
``bash``
cd /home/lepr/workspace/configs && cd gnome && cd tests && ./run_test_wrapper.sh --help 2>&1 | head -5
Current result: Exit code 1
Problem: No stderr, no indication what failed (cd? script? pipe?)
### Example 3: Conditional with subshell
``bash``
test -f /nonexistent/file && echo "exists" || (echo "not found" && exit 1)
Current result: Exit code 1 with partial output ("not found" in stderr)
Problem: Better than examples 1-2, but still unclear without context
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.31
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Xterm
Additional Information
_No response_
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗