Embedded quotes and empty args vanish before native commands see them
args quoting · case
Affectsnode, powershell 51, pwsh 7, windows
Fails assilent
Mechanismnative argv rebuild
Safe fixps native argument passing
Symptom
Section titled “Symptom”A native command receives mangled arguments: embedded double quotes are stripped, empty-string arguments disappear entirely, JSON payloads arrive corrupted. The PowerShell side looks correct; only the receiving program sees the damage.
node -e "console.log(JSON.stringify(process.argv.slice(1)))" '{"key": "value"}' ""# Legacy argument passing: quotes stripped, empty arg dropped:# ["{key: value}"]PowerShell historically rebuilt a command line string for native processes instead
of passing an argument vector, re-quoting by heuristic. PR #14692 introduced
$PSNativeCommandArgumentPassing = 'Standard' (7.2+) using .NET ArgumentList to
fix quotes/empty/space handling — and PR #15408 immediately had to carve out a
Windows legacy mode because some Windows CLIs (msiexec-style KEY="value")
depended on the broken behavior. The trap is version- and platform-dependent.
Workaround
Section titled “Workaround”- Pin behavior explicitly on 7.2+:
$PSNativeCommandArgumentPassing = 'Standard'(or'Legacy'when a Windows CLI needs it). - Pass complex payloads via files or stdin, never inline JSON arguments, when 5.1 must be supported.
- Test argument round-trips on every runtime you claim to support.