Skip to content

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

Closed as not planned

Description

@JFast96

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)

Activity

  1. github-actions commented on Aug 13, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions