Skip to content

fix(interpreter): exec N>&- closes the descriptor for real - #2610

Merged
chaliy merged 1 commit into
mainfrom
claude/closed-fd-write
Oct 8, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/closed-fd-write

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

What changed

exec 1>&- and exec 2>&- now close the descriptor instead of quietly
reverting to the caller's stream. A later write to a closed descriptor is
dropped, the command reports write error: Bad file descriptor under its own
name, and its status is 1. When fd 2 is closed too, the report is swallowed but
the status still fails.

Why

Scripts use exec 1>&- to prove nothing writes to stdout afterwards. Bashkit
printed the output and succeeded, so such a script passed in bashkit and failed
in bash.

Before / After

Script:

exec 1>&-
echo x
stdout stderr status
bash 5.2 (empty) line 2: echo: write error: Bad file descriptor 1
bashkit before x (empty) 0
bashkit after (empty) bash: line 2: echo: write error: Bad file descriptor 1

(bash names the script path where bashkit says bash:; the interpreter does not
track a script path, which is a separate known gap.)

Risk

Low. Confined to the exec fd table: a new FdTarget::Closed variant that only
exec N>&- produces. Everything else routes as before.

L-PROC-001 now also records that an exec redirect inside a subshell or a
bash -c child does not take effect, since only the outermost command loop
routes the exec fd table. That is pre-existing behavior, found while testing
this, and not changed here.

Checklist

  • cargo test -p bashkit --lib (2859 passed)
  • cargo test -p bashkit --test integration (1355 passed)
  • bash_comparison differential tests against real bash
  • cargo clippy -p bashkit --all-targets -- -D warnings
  • cargo fmt --all --check
  • cargo test -p bashkit-cli (56 passed)
  • just check-okf, just check-doc-links
  • Stack probe: 2016 KB, inside the two-MiB TM-DOS-020 budget
  • Knowledge updated (log.md, limitations.md)

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

A write to a descriptor closed with `exec 1>&-` was still printed and
still succeeded. It now behaves like bash: the data is dropped, the
command reports `write error: Bad file descriptor` under its own name,
and its status is 1. A closed fd 2 swallows the report but keeps the
status.

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

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

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 4b32ac3 Commit Preview URL

Branch Preview URL
Oct 07 2026, 10:59 PM

@chaliy
chaliy merged commit f286bf3 into main Oct 8, 2026
44 checks passed
@chaliy
chaliy deleted the claude/closed-fd-write branch October 8, 2026 01:20
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