fix(executor): handle Windows shell runtimes robustly#709
Merged
mksglu merged 1 commit intoMay 25, 2026
Merged
Conversation
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.
What / Why / How
While dogfooding context-mode from Codex on Windows,
ctx_execute(language: "shell")andctx_batch_executecan fail before user code runs:Codex sets
SHELLto Windows PowerShell in this environment. context-mode correctly writes a temporaryscript.ps1, but then runs it aspowershell -File <script>. On normal Windows PowerShell installs where the effective execution policy isRestricted, that temp script is blocked.This patch keeps the fix narrow to Windows shell handling:
-NoProfile -ExecutionPolicy Bypass -File.cmdtemp scripts pluscmd.exe /d /s /cwhen the selected shell is cmdSHELLoverrides, so Windows-hosted execution falls back to Git Bash instead ofC:\Windows\System32\bash.exeExecutionPolicy Bypasshere is process-scoped for this spawned PowerShell process only; it does not change machine/user policy.Validation
pnpm exec vitest run tests/runtime.test.ts -t "SHELL env var|Windows bash gets bash -c source pattern|Windows powershell gets process-scoped execution policy bypass|Windows pwsh gets process-scoped execution policy bypass|Windows cmd gets cmd /c pattern|Unix bash gets direct file path" --reporter=dotpnpm exec vitest run tests/executor.test.ts -t "PowerShell shell runtime executes generated script|buildCommand returns shell command array|buildScriptFilename: POSIX shell on Windows has NO extension|buildScriptFilename: cmd on Windows uses .cmd extension|buildScriptFilename: PowerShell on Windows uses .ps1 extension|buildScriptFilename: shell on Unix keeps .sh extension" --reporter=dotPolyglotExecutorsmoke on this Windows machine: Windows PowerShell 5, pwsh 7, Git Bash, cmd all executed successfully.server.bundle.mjs:ctx_executeandctx_batch_executesucceeded for Windows PowerShell 5, pwsh 7, Git Bash, cmd, and WSL-bash-shim fallback.pnpm run typecheckpnpm run build