fix(sandbox): stop creating an undeletable "nul" file from cmd-style redirects#4257
Merged
Conversation
… device The model often appends Windows cmd idioms like `2>nul` / `>nul` to discard output. reasonix runs commands under bash or PowerShell (never cmd.exe), where `nul` is an ordinary filename, not the null device — so the redirect created an undeletable file named `nul` (a Windows reserved name) in the workspace root, which breaks builds and git operations. Rewrite those redirects to `/dev/null` (bash) / `$null` (PowerShell) in argv, the single point every shell invocation funnels through. Non-redirect uses of "nul" (echo nul, grep nul, nul.txt) are left untouched. Closes #4252
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4252
Problem
On Windows, an undeletable file named
nulkeeps appearing in the workspace root. It can't be removed by Explorer orcmd(reserved device name) — onlyrmfrom git bash works — and it breaks builds andgitoperations.Root cause
The model frequently appends the Windows cmd idiom
2>nul/>nulto discard output. reasonix runs shell commands under bash or PowerShell, nevercmd.exe. Onlycmd.exetreatsnulas the null device — bash and PowerShell treat it as an ordinary filename, so2>nulliterally creates a file callednulin the cwd (the workspace root).Reproduced on this box:
Fix
Normalize cmd-style
nulredirects (>nul,2>nul,1>>NUL,&>nul, …) to the target shell's real null device —/dev/nullfor bash,$nullfor PowerShell — inShell.argv, the single point every shell invocation funnels through. Non-redirect uses of the word (echo nul,grep nul file,cat nul.txt,rm nul) are left untouched (RE2 has no lookahead, so the trailing delimiter is captured and re-emitted).Validation
TestNormalizeNulRedirect(rewrite cases + negatives) andTestArgvNormalizesNulRedirect.echo hi 2>/dev/null/2>$null) creates nonulfile under bash or PowerShell, whereas the original2>nuldid.go test ./internal/sandbox/+go vetpass.