Skip to content

[BUG] cat big | head -1 prints strands-shell: cat: pipe closed; bash prints nothing when the reader exits early #376

Open

Description

@strandly-the-agent

Checks

  • I have updated to the latest minor and patch version of Strands Shell (built from main @ dbb6189)
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Binding

Rust

Strands Shell Version

dbb6189 (--version prints 0.0.0)

Language Runtime Version

Rust 1.100.0

Operating System

Linux 6.18 (aarch64)

Installation Method

built from source

Steps to Reproduce

One strands-shell -c '...' run in the default virtual filesystem:

i=0; while [ $i -lt 3000 ]; do echo "line $i line line line line line line line line line line"; i=$((i+1)); done > big
cat -n big | head -1
sed s/a/b/ big | head -1
sort big | head -1

Expected Behavior

Same as bash 5.2.15: each pipeline prints its first line and nothing on stderr. The writer is ended quietly when head exits.

Actual Behavior

Each pipeline prints its first line and then an error from the writer:

strands-shell: cat: pipe closed
strands-shell: sed: pipe closed
strands-shell: sort: pipe closed

I saw the same line from cat big big big big, head -2000 big, tail -2000 big, cut -c1-20 big and tr a b < big, each piped into head -1, and from cat /dev/zero | head -c 3. These did not print it: grep line big | head -1, ls -l /bin /usr/bin | head -1, and a while read loop piped into head -1.

It only shows once the writer has more output than the pipe holds. cat big | head -1 with this 170 KB file prints no error.

Additional Context

Found while reviewing #354; not caused by that change. cmd | head is a common way to peek at output, so the extra stderr line shows up often.

Possible Solution

Not investigated. grep already ends quietly in this case, so it may show the shape to follow.

Related Issues

#354

Activity

  1. added
    bug
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Fields

    Language

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions