Skip to content

[bug] '<> file' does not create the missing file (GNU opens O_RDWR|O_CREAT; rubash fails ENOENT) #264

Closed

Description

@caomengxuan666

Found by: wt5/audit source lane (2026-09-28), script-file-verified against WSL GNU Bash 5.3.0.

Summary: <> file (r_input_output) must open read-write with create, so redirecting a nonexistent file creates it empty. rubash's open fails with ENOENT and the whole command errors.

GNU C source owner: third_party/bash/make_cmd.c:682 make_redirection():

case r_input_output:		/* <>foo */
  temp->flags = O_RDWR | O_CREAT;

consumed by redir.c:702 redir_open() -> open(filename, flags, 0666).

Reproducer (tests/fixtures/audit/a2-iso.sh case 1; raw: target/issue-suites/results/source-audit/out/a2-iso.diff):

printf 'xy' <> brandnew; echo "rc=$?"; cat brandnew; echo "size=$(wc -c < brandnew)"

GNU 5.3.0: xy (printf writes to fd 1, redirect is on stdin), rc=0, size=0 — file brandnew was created empty by the <> open.
rubash: stderr line 5: cat: brandnew: No such file or directory + line 5: brandnew: No such file or directory, size= — the <> open itself failed; command aborted rc=1.

Rubash owner: src/executor/redirection.rs input-output open path (rw open without create flag), fed by src/parser/redirections.rs.

Classification: rubash-caused. Breaks the exec {fd}<>file read-write channel idiom and <> $tty-style device opens.

Activity

  1. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(commit 3aec2a83,lane wt6/fdio;GNU 引用与 14 探针矩阵/真基线切片验证见提交——redir/read/heredoc/procsub 全 0 差异,regression 24/24)。感谢报告!

  2. added
    bug
    area:fd
    on Oct 17, 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

    area:fdbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions