Skip to content

fix(redirect): route /dev/stdout, /dev/stderr, /dev/fd/N to descriptors - #2512

Merged
chaliy merged 1 commit into
mainfrom
claude/project-thread-fwdh7i
Oct 6, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/project-thread-fwdh7i

Conversation

@chaliy

@chaliy chaliy commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

Redirections to /dev/stdin, /dev/stdout, /dev/stderr and /dev/fd/N now behave like on Linux: they alias the descriptor's current target (> /dev/stderr is >&2, > /dev/fd/3 is >&3, < /dev/stdin keeps stdin, exec 3>/dev/stderr dups fd 2). They are resolved at the interpreter level like /dev/null and never reach the VFS. Covers the fast redirect path, the fd-table path (mixed 2>&1 + file), &>, >>, variable targets and .. spellings.

First PR of the "closer to real bash" roadmap (Step 1, fidelity bugs).

Why

echo err > /dev/stderr silently wrote a 3-byte regular file /dev/stderr in the VFS and printed nothing. Agents use this pattern constantly for error messages, so errors vanished.

Before / After

$ bashkit -c 'echo err > /dev/stderr; ls -l /dev'
# before: (no output on stderr)
-rw-r--r--   3 ... stderr        <- regular file created
# after:
err                               <- on stderr, no file created

Real bash 5.2 cross-checked for the tricky shapes: 2>&1 >/dev/stderr sends both streams to stdout; exec 3>/dev/stderr; echo x >&3 goes to stderr.

Risk

  • Low
  • Only redirect targets whose normalized path is exactly /dev/std{in,out,err} or /dev/fd/<digits> change behaviour. Process-substitution paths (/dev/fd/proc_sub_*) are untouched. Builtin file operands (tee /dev/stderr, cat /dev/stdin) are a follow-up, noted in knowledge/foundations/vfs.md.

Checklist

  • Tests added or updated (12 integration tests, 8 spec cases)
  • Backward compatibility considered

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

echo err > /dev/stderr wrote a regular VFS file named /dev/stderr and
printed nothing. Resolve /dev/stdin, /dev/stdout, /dev/stderr and
/dev/fd/N at the interpreter level like /dev/null, as dups of the
descriptor's current target, across the fast, fd-table and exec paths.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy chaliy self-assigned this Oct 6, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit ec71cd6 Commit Preview URL

Branch Preview URL
Oct 06 2026, 07:14 PM

@chaliy
chaliy merged commit db7f538 into main Oct 6, 2026
44 checks passed
@chaliy
chaliy deleted the claude/project-thread-fwdh7i branch October 6, 2026 19:40
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.

1 participant