Skip to content

fix(shell): encode PowerShell commands to preserve multi-line output - #42274

Open
vladislav-miroshnikov wants to merge 2 commits into
anomalyco:devfrom
vladislav-miroshnikov:shell-encoded-command
Open

fix(shell): encode PowerShell commands to preserve multi-line output#42274
vladislav-miroshnikov wants to merge 2 commits into
anomalyco:devfrom
vladislav-miroshnikov:shell-encoded-command

Conversation

@vladislav-miroshnikov

@vladislav-miroshnikov vladislav-miroshnikov commented Aug 13, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #41983

Type of change

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

What does this PR do?

On Windows, a configured PowerShell .cmd or .bat wrapper passes through cmd.exe, which treats newlines in a -Command argument as command separators. Only the first line can reach PowerShell.

This uses PowerShell's UTF-16LE -EncodedCommand form for wrapper scripts, while preserving -Command for direct powershell.exe and pwsh.exe executables. That keeps multiline wrapper commands intact without reducing the command-line budget for direct executables.

How did you verify your code works?

  • cd packages/opencode && bun test test/tool/shell.test.ts — 24 pass, 0 fail
  • cd packages/core && bun test test/shell.test.ts — 7 pass, 0 fail
  • cd packages/opencode && bun typecheck
  • cd packages/core && bun typecheck

Portable tests verify the exact argument form and UTF-16LE round trip. A Windows-only test creates a real pwsh.cmd wrapper and verifies all three lines of a multiline command reach PowerShell.

Screenshots / recordings

N/A — no UI change.

Checklist

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

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.

bash tool drops stdout for every command after a newline; only the first command's output is captured

1 participant