Skip to content

fix(read): last stdin redirect wins for < file + <<< herestring - #1431

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix-1391-stdin-order
Oct 23, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix-1391-stdin-order

Conversation

@arookieofc

Copy link
Copy Markdown
Member

Summary

Fixes read (and other shell-internal stdin consumers) to use the LAST stdin redirect when < file precedes <<< herestring.

Changes

  • src/executor/read_io.rs: detects when the last fd-0 redirect is a herestring and skips the file-redirect path

Issues

Fixes #1391

Testing

  • New regression test: tests/issue1391_stdin_redirect_order.rs (3 tests, all pass)
  • Verified against GNU bash 5.3: < f <<< over → over, <<< over < f → filecontent

GNU redir.c applies redirects in order; the last fd-0 input wins.
The read builtin checked cmd.redirect_in (first file redirect) before
the herestring path, so 'read x < f <<< over' read the file.

Fixes #1391
@caomengxuan666
caomengxuan666 merged commit 4347880 into master Oct 23, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix-1391-stdin-order branch October 30, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] read/mapfile (and groups) use the FIRST stdin redirect when < file precedes <<< — bash uses the LAST

2 participants