[BUG] Input redirection broken in Bash tool

Resolved 💬 5 comments Opened Jul 1, 2025 by bitplane Closed Aug 20, 2025

Human summary

Claude tries to run ./program < file.txt in its Bash tool, but the tool fails to pass the file contents in. Probably sandboxing issue.

bash -c "./program < file.txt" works, and cat file.txt | ./program works too.

It'd be okay if it knew not to use <, but since it expects it to work it costs a lot of tokens due to being given a bum steer by the confusion.

Machine generated spew follows:

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.38 (Claude Code)
  • Operating System: Linux 6.11.0-28-generic (Ubuntu 24.04.2 LTS)
  • Terminal: gnome terminal -> tmux -> bash

Bug Description

The Bash tool does not handle input redirection (<) correctly. Commands using stdin redirection produce no output, while the same commands work correctly with pipes. This affects standard Unix workflows and Makefile patterns.

Steps to Reproduce

  1. Create a test file: echo 'test content' > test.txt
  2. Create a simple C program that reads from stdin:

``c
#include <stdio.h>
int main() {
char buffer[256];
while (fgets(buffer, sizeof(buffer), stdin)) {
printf("%s", buffer);
}
return 0;
}
``

  1. Compile: gcc -o test_program test.c
  2. Run with input redirection: ./test_program < test.txt
  3. Observe no output
  4. Run with pipe: cat test.txt | ./test_program
  5. Observe correct output

Expected Behavior

  • ./test_program < test.txt should output the contents of test.txt
  • Process substitution <() should work in Makefiles without requiring bash -c
  • Standard input redirection should work as in a normal bash shell

Actual Behavior

  • Input redirection (<) produces no output - the program reads 0 bytes from stdin
  • Process substitution <() fails with "Syntax error: '(' unexpected"
  • The same commands work only when:
  • Using pipes instead: cat file | ./program
  • Explicitly wrapped in bash: bash -c './program < file'

Additional Context

  • The Bash tool reports it's running bash 5.2.21(1)-release
  • File descriptor redirection also fails: exec 3< file && cat <&3
  • This breaks common Unix patterns and makes it difficult to run standard Makefiles
  • The issue appears to be a sandboxing/security restriction rather than a shell issue

View original on GitHub ↗

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