[BUG] Bash commands succeed but report exit code 1

Resolved 💬 3 comments Opened Jan 31, 2026 by v-za Closed Feb 3, 2026

[BUG] Bash commands succeed but report exit code 1

Environment

  • Claude Code Version: 2.1.27 (native binary)
  • Installation: ~/.local/share/claude/versions/2.1.27
  • OS: macOS (Darwin 24.4.0, arm64)
  • Shell: zsh 5.9

Description

All Bash tool commands report "Error: Exit code 1" even when the command succeeds and produces correct output.

Reproduction Steps

  1. Start a new Claude Code session
  2. Run any simple command: echo "test"
  3. Observe output shows "test" correctly
  4. But error displays: "Error: Exit code 1"

Expected Behavior

  • Command: echo "test"
  • Output: test
  • Exit code: 0

Actual Behavior

  • Command: echo "test"
  • Output: test
  • Exit code: 1 (incorrect)

Evidence

The actual exit code inside the command is 0:

echo "test" && echo "exit code: $?"
# Output: test
#         exit code: 0
# But Claude Code reports: Error: Exit code 1

Investigation Performed

Extensive analysis ruled out user configuration:

| Checked | Result |
|---------|--------|
| Shell hooks (precmd/preexec) | None installed |
| zshrc exit code | Ends with true |
| Claude Code hooks | All exit 0 or 2 |
| uv run wrapper | Properly propagates exit codes |
| Sandbox mode | Disabled |
| Multiple installations | Only v2.1.27 active |
| Environment variables | No BASH_ENV set |
| TTY/PTY handling | Graceful fallbacks |

Related Issues

  • #11480 - Sandbox CWD tracking (similar symptom, different cause)
  • #12115 - Bash commands fail with exit code 1 (no output - different)
  • #4809 - PostToolUse hook exit code issues

Additional Context

  • Happens on every command, not intermittently
  • Output is always correct, only exit code is wrong
  • Fresh sessions exhibit same behavior
  • Both simple (pwd) and complex commands affected

View original on GitHub ↗

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