Repository navigation
Description
Follow-up to #154. That issue kept cmd.exe's operators out of the argument path by adding wmux.ps1, and that part works. But a value containing double quotes is still corrupted on the way to the CLI — through wmux.ps1 as well as wmux.cmd — and the CLI then silently drops every flag that follows it.
Seen on wmux 2.13.0, Windows PowerShell 5.1.26100.9444.
Repro
Three spawns that differ only in the --cmd value. --label and --workspace are identical and valid in all three:
wmux agent spawn --cmd 'hostname' --label A --workspace <ws>
wmux agent spawn --cmd 'powershell -NoProfile -Command Start-Sleep' --label B --workspace <ws>
wmux agent spawn --cmd 'powershell -NoProfile -Command "Start-Sleep 30"' --label C --workspace <ws>Read back with wmux agent list:
| case | cmd intact | --label honoured |
--workspace honoured |
|---|---|---|---|
| A — no spaces | yes | yes | yes |
| B — spaces, no quotes | yes | yes | yes |
| C — embedded quotes | no | no | no |
Case C records cmd as powershell -NoProfile -Command Start-Sleep — the 30 and both quotes are gone, so the agent runs a different, truncated command than the caller asked for. label comes back as powershell, i.e. the cmd.split(/\s+/)[0] default, and the agent is filed under the focused workspace as though --workspace had never been passed.
Nothing reports a problem: exit code 0, a normal {agentId, surfaceId} reply, an agent that starts and runs.
Identical through F:\wmux\resources\cli-bin-ps\wmux.ps1 (bare wmux, which is what PATH resolves first) and through cli-bin\wmux.cmd. The bash shim is unaffected — the same command from Git Bash preserves cmd, label and workspace exactly.
Cause
Two layers, and the second is the one that makes it silent.
-
Windows PowerShell 5.1 does not escape embedded double quotes when it builds a native process's command line.
@argsinwmux.ps1splats natively and so avoids cmd.exe (which is what PowerShell callers lose argument quoting through wmux.cmd:>in any free-form argument silently redirects instead of reaching the CLI #154 fixed), but it does not fix this: the value reachesnodesplit into several argv elements with the quotes eaten. PowerShell 7.3+ hasPSNativeCommandArgumentPassingfor exactly this; 5.1 has nothing, so the shim has to escape the value itself. -
agentSpawninsrc/cli/wmux.tsparses flags positionally —for (let i = 0; i < rest.length; i += 2), readingrest[i]as a flag andrest[i+1]as its value. One extra token anywhere puts every later flag on an odd index, where the loop never looks at it. There is no unknown-token check, so a dropped--workspaceor--paneis indistinguishable from one that was never passed, and--labelquietly falls back to a default that makes the result look plausible.
Layer 2 is worth fixing regardless of layer 1: a scanning parser (match a flag wherever it appears, error on an unrecognised token) would turn a mangled command line into a loud failure instead of a truncated command in the wrong workspace. spawn-batch and layout use the same pairwise shape.
Why it bites
--cmd is the one argument that is expected to carry a quoted inner command line, so this fires on the realistic call and not on the simple one. It also silently defeats the --workspace/--pane workaround for #246, which is how I ran into it.
It may also be the real explanation for a long-standing note in my own setup docs that "--cwd is ignored by wmux agent spawn" — --cwd is normally written after --cmd. I have not confirmed that specific case.
Activity
fix(agent): spawn defaults to the caller's workspace, and the CLI ref…
amirlehmam commentedon Sep 29, 2026
Fixed in v2.14.0, both layers.
wmux.ps1now builds node's command line itself with CommandLineToArgvW quoting on PowerShell < 7.3 (orPSNativeCommandArgumentPassing = Legacy), still without cmd.exe; your case C round-trips exactly on 5.1 and pwsh 7.6. Andagent spawn/spawn-batch/layout gridshare a scanning flag parser that exits 1 naming the offending token (stray token, flag without a value, repeated flag) instead of silently dropping everything after it.Merge pull request #255 from mkh63d: reap finished agents, keep waves…
fix(sidebar): report a set-indicator that changed nothing; scan its f…
feat(sidebar): add set-indicator / clear-indicator for a workspace pi…