Skip to content

fix(cat): create all output files for > f1 > f2 with heredoc - #1432

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix-1392-multi-output
Oct 23, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix-1392-multi-output

Conversation

@arookieofc

Copy link
Copy Markdown
Member

Summary

Fixes in-process cat to create/truncate ALL output redirect targets when multiple > redirects are present with a heredoc.

Changes

  • src/executor/external_file_builtins.rs: heredoc branch of external_cat now opens earlier > redirects for side effects
  • src/executor/external_finish.rs: write_cat_output does the same for non-heredoc paths

Issues

Fixes #1392

Testing

  • New regression test: tests/issue1392_multi_output_redirect.rs (2 tests, all pass)
  • Verified: cat <<H > f1 > f2 creates empty f1, f2 has content; pre-existing f1 truncated

GNU redir.c opens ALL output redirects in order (each created/truncated);
only the last becomes stdout. The in-process cat heredoc path only opened
the last redirect, leaving f1 uncreated.

Fixes #1392
@caomengxuan666
caomengxuan666 merged commit a3087d6 into master Oct 23, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix-1392-multi-output 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] stdin redirect + > f1 > f2 never creates/truncates f1 — bash creates both (empty f1)

2 participants