GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Multi-line shell command runs only the first line on Windows/PowerShell (regression 2.2.5 to 2.2.6) · Issue #62877 · anomalyco/opencode

Multi-line shell command runs only the first line on Windows/PowerShell (regression 2.2.5 to 2.2.6) #62877

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
Multi-line shell command runs only the first line on Windows/PowerShell (regression 2.2.5 to 2.2.6)#62877
Copy link
Labels
pending closetriaging

Description

@jcompagner
jcompagner
opened on Nov 9, 2026
Issue body actions

Summary

A multi-line shell tool command (several statements on separate lines) only runs its first line on Windows/PowerShell in OpenCode 2.2.6. The same command runs every line on 2.2.5. This is a regression between 2.2.5 and 2.2.6.

Environment

  • OS: Windows (arm64)
  • Shell: PowerShell (resolved as a Microsoft Store app-execution alias pwsh.exe; Windows PowerShell powershell.exe behaves the same)
  • Driven through OpenChamber 2.7.0, which lets me point at different OpenCode installs without changing anything else. I reproduced it by switching only the OpenCode binary.

Reproduction

Run a shell command whose value is multiple statements separated by real newlines, e.g.:

Write-Output "L1"
Write-Output "L2"
Write-Output "L3"
  • OpenCode 2.2.6 → output is only L1. The later lines never run (verified separately: a first line that creates a file runs, a second line that writes to it does not).
  • OpenCode 2.2.5 → output is L1 / L2 / L3, all lines run.

Version discriminator

Everything except the OpenCode version was held constant (same OpenChamber 2.7.0, same machine, same shell):

OpenCode Build Multi-line result
2.2.6 bundled desktop CLI only L1
2.2.6 npm @opencode/[email protected] only L1
2.2.5 npm @opencode/[email protected] L1 L2 L3

Two independent 2.2.6 builds both truncate; 2.2.5 does not. So it is the OpenCode version, not the build origin or packaging.

What we investigated inside OpenCode (and ruled out)

We dug through the shell path in the v2.2.6 source and tested each layer directly. None of these is the cause — the multi-line command survives all of them:

  • PowerShell itself — invoking pwsh/powershell.exe with a multi-line -Command argument directly (PowerShell &, Node spawnSync, Bun Bun.spawn with stdin: "ignore") runs every line.
  • The Store app-execution alias (relevant since fix(core): find Microsoft Store PowerShell 7 on Windows fix(core): find Microsoft Store PowerShell 7 on Windows #61952, which changed which pwsh is selected) — the alias and the real powershell.exe both run every line.
  • ShellSelect.args and the spawn (packages/core/src/shell/select.ts, packages/core/src/shell.ts) — the ps branch returns ["-NoLogo","-NoProfile","-NonInteractive","-Command", command] and the newlines stay intact in that single argument. A unit test that rebuilds this argv and spawns it passes (all lines run).
  • The full ShellTool → shell.create → spawn chain — we wrote and ran a test in packages/core/test that drives the real ShellTool with a two-statement multi-line PowerShell command (each line writing a marker file). Both marker files were written, status completed. So the whole tool-execution chain in v2.2.6 handles multi-line correctly.
  • Code Mode string literals — a multi-line template string inside a Code Mode program keeps all its newlines; the decoding is not the culprit.
  • OpenChamber's side — OpenChamber does not execute or transform the shell command; its only relevant 2.7.0 change was bumping OpenCode 2.2.5 → 2.2.6. It was held constant across the tests above.

Where that leaves it (not yet pinned)

Since every testable code unit in the v2.2.6 shell/tool path handles multi-line correctly, the newline loss appears to happen before shell.create — in how the tool-call command argument is carried from the model/tool-call transport into tool execution, rather than in a pure function we could unit-test. We could not localize it to a single line without live instrumentation of the incoming command on a running 2.2.6 server.

The diff to look at is small: v2.2.5..v2.2.6. In packages/codemode that range includes ffde0f7d47 feat(codemode): add a bytecode VM engine and adcfc83d19 feat(codemode): let programs import globals by Node module name — these are leads for how a multi-line string argument might be decoded differently, not a proven cause.

Workaround

Put the multi-line logic in a script file and run it as a single-line command, e.g. pwsh -NoProfile -File <script.ps1>. That is unaffected.

Activity

  1. opencodejr commented on Nov 9, 2026

    @opencodejr
    opencodejrBot
    on Nov 9, 2026
    Contributor
    More actions

    Thanks for the thorough investigation and the version table. It narrowed this down quickly.

    I think this is a duplicate of #62512. That's the same 2.2.6 regression with the same cause: since #61952, OpenCode can choose the Microsoft Store pwsh.exe app-execution alias. The process launcher can't check that alias directly, so it starts it through cmd.exe /d /s /c, and cmd.exe stops reading the command at the first newline. Only the first line runs, and the exit code is still 0. Your direct pwsh tests didn't go through cmd.exe, which is why every part you tested looked fine.

    Possible duplicates and related items, ordered from most to least likely:

    • v2.2.6 regression: shell tool returns empty output (exit 0) for every command when Store PowerShell 7 resolves to its app-execution alias #62512: same 2.2.6 regression with the Store PowerShell alias. The output was empty there only because a plugin adds a setup line before every command.
    • fix(core): keep multi-line commands intact for Store PowerShell 7 #62522: the merged fix. It launches the real packaged pwsh.exe behind the alias, so every line runs. It landed after 2.2.6 and should be in the next release.
    • fix(shell): encode PowerShell commands to preserve multi-line output #42274: an older, related fix for multi-line commands lost when PowerShell is started through a .cmd/.bat wrapper via cmd.exe.

    Until the next release, you can set "shell" in your config to the full path of the packaged pwsh.exe, or keep using your script-file workaround.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. For example, reply if it also happens with a regular, non-Store powershell.exe or pwsh.exe set as the shell.

  2. opencodejr
    added
    pending close
    triaging
    on Nov 9, 2026
  3. opencodejr
    closed this as duplicateon Nov 10, 2026
  4. opencodejr commented on Nov 10, 2026

    @opencodejr
    opencodejrBot
    on Nov 10, 2026
    Contributor
    More actions

    Closing this as a duplicate of #62512, since there's been no reply in the last day saying how this problem is different.

    It's the same 2.2.6 regression: the Microsoft Store pwsh.exe alias gets started through cmd.exe, and cmd.exe drops everything after the first line of the command. The fix in #62522 has been merged and should be in the next release after 2.2.6. Until then, you can set "shell" to the full path of the packaged pwsh.exe, or keep using your script-file workaround.

    If it still happens after upgrading, or also happens with a regular, non-Store PowerShell, please comment here and we can reopen it. Thanks again for the detailed investigation.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending closetriaging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.