[BUG] Bash tool error reporting insufficient for chained commands (only "Exit code 1")

Resolved 💬 8 comments Opened Nov 3, 2025 by lene Closed Jan 19, 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?

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

  1. Limited diagnostic information: Exit code alone doesn't explain what failed or why
  2. Inefficient retry loops: Claude must guess at fixes and retry variations
  3. Wasted resources: Multiple attempts without clear feedback
  4. 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

  1. Always capture and return stderr alongside exit codes
  2. For chained commands, show which command failed (if detectable via set -e or similar)
  3. Include shell error messages (e.g., "No such file or directory", "Permission denied")
  4. 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_

View original on GitHub ↗

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