anomalyco / anomalyco/opencode

Shell notes for PowerShell 5.1 recommend backtick escaping, which corrupts commands

Open
#42,402 1 comment 0 reactions 1 assignee View on GitHub

@Hona is already working on this.

Since Aug 13, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

On Windows PowerShell 5.1, double quotes passed to an external program are silently
stripped and the argument can split. Nothing errors and the exit code is 0, so commands
corrupt instead of failing. The shell notes make it worse by telling the agent to escape
with the backtick, which for this case splits the argument even further.

Plugins

N/A

OpenCode version

1.18.18 (Desktop)

Steps to reproduce
node -e "console.log(JSON.stringify(process.argv.slice(1)))" 'a "b c" d'

expected  ["a \"b c\" d"]
actual    ["a b","c d"]

Real case: ssh host 'sed -i "s/\r$//" file' arrived unquoted and deleted every trailing
letter r instead of carriage returns. It reported success, so I only noticed hours later.

The 5.1 notes say "Escape special characters with the PowerShell backtick character".
For this failure that makes it worse:

plain            ["a b","c d"]      2 args
backtick         ["a ","b","c d"]   3 args
backslash \"     ["a \"b c\" d"]    correct
single quotes    ["a 'b c' d"]      correct

Fixed upstream in PowerShell 7.3 via $PSNativeCommandArgumentPassing = 'Standard', which
doesn't exist in 5.1. Shell.win() already prefers pwsh, so this only hits users without
PowerShell 7+. Encoding the command doesn't help; the corruption is on the PowerShell to
child process hop.

Screenshot and/or share link

N/A, no UI changes.

Operating System

Windows 10 Home 22H2 (build 19045)

Terminal

OpenCode Desktop app, shell is Windows PowerShell 5.1.19041.7663 (pwsh not installed)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.