Skip to content

fix(opencode): prevent literal nul file creation on posix#15183

Open
cyberprophet wants to merge 3 commits intoanomalyco:devfrom
cyberprophet:fix/nul-redirection-on-posix
Open

fix(opencode): prevent literal nul file creation on posix#15183
cyberprophet wants to merge 3 commits intoanomalyco:devfrom
cyberprophet:fix/nul-redirection-on-posix

Conversation

@cyberprophet
Copy link

@cyberprophet cyberprophet commented Feb 26, 2026

Issue for this PR

Closes #11403

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes repeated creation of a literal nul file in project directories during shell tool usage.

Changes made:

  • added a small normalization utility that rewrites redirection targets nul/NUL to /dev/null on non-Windows platforms
  • applied that normalization in both shell execution paths (bash tool and session shell runner)
  • changed child stdin from ignore to pipe and explicitly closed it to avoid null-device handling side effects
  • added focused tests for redirection normalization behavior

Why this works:

  • on POSIX systems, nul is a normal filename, not a device; rewriting redirections prevents accidental file creation
  • explicit stdin close avoids relying on runtime-specific ignore behavior

How did you verify your code works?

  • Added unit tests in packages/opencode/test/util/redirection.test.ts
  • CI checks on this PR show typecheck and unit tests passing on linux/windows
  • Local verification command output in my environment had dependency/tooling gaps (glob, tsgo, @opentui/solid/preload), noted transparently in prior description

Screenshots / recordings

N/A (non-UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Feb 26, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@cyberprophet
Copy link
Author

Updated the PR description to match the required template and kept the issue linkage (). Please re-check compliance constraints.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 26, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@cyberprophet
Copy link
Author

Updated the PR description to match the required template and kept the issue linkage (Closes #11403). Please re-check compliance constraints.

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.

Unexpected file named "nul" is repeatedly created after updating OpenCode

1 participant