claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Claude Code freezes when executing heredoc piped to script via /dev/stdin

Open patrickstump opened this issue 2 months ago • 0 comments

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?

Description

Claude Code consistently freezes/hangs when executing bash commands that use a heredoc pattern piped to a script via /dev/stdin. The UI shows a status message (e.g., "Flibbertigibbeting...") indefinitely with no progress, and the session must be interrupted.

Environment

  • Claude Code version: 2.0.75
  • OS: macOS Darwin 23.6.0
  • Shell: zsh

Steps to Reproduce

  1. Have Claude Code execute a command using this pattern:

cat << 'EOF' | ./bin/ansible-playbook.sh /dev/stdin 2>&1

  • name: Test playbook hosts: some-host tasks:
    • name: Do something debug: msg: "Hello" EOF
  1. Claude Code freezes during execution
  2. Partial output may appear, but the tool never returns
  3. Session must be interrupted (Ctrl+C or similar)

Expected Behavior

The heredoc command should execute and return output like any other bash command.

Actual Behavior

Claude Code becomes unresponsive. Based on partial output seen before the freeze, the underlying command appears to execute, but the Bash tool never returns results and the session hangs indefinitely.

Workaround

Creating an actual file first, then executing it works reliably:

This freezes:

cat << 'EOF' | ./script.sh /dev/stdin content EOF

This works:

1. Use Write tool to create file

2. Run: ./script.sh ./temp-file.yml

Additional Context

  • The underlying command works fine when run directly in terminal
  • The freeze occurs specifically with: heredoc + pipe + /dev/stdin
  • Reproducible across multiple attempts in the same session
  • May be related to how stdin buffering or EOF handling works when the Bash tool spawns subprocesses

Reproduction Rate

100% - Every attempt to use this pattern resulted in a freeze.

What Should Happen?

The heredoc command should execute and return output like any other bash command.

Error Messages/Logs


Steps to Reproduce

  1. Have Claude Code execute a command using this pattern:

cat << 'EOF' | ./bin/some-script.sh /dev/stdin 2>&1

content: here more: content EOF

  1. Claude Code freezes during execution
  2. Partial output may appear, but the Bash tool never returns
  3. Session must be interrupted (Ctrl+C or Escape)

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.0.75

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

patrickstump avatar Dec 21 '25 20:12 patrickstump