-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
exec tool mangles PowerShell $ syntax on Windows (dollar sign interpolation) #16821
Description
Summary
On Windows with shell=powershell, the exec tool interpolates/strips $ characters in command strings before passing them to the shell. This breaks any PowerShell command using $_, $env:, $variable, etc.
Reproduction
Any exec call containing PowerShell variables:
exec: Get-ChildItem | Where-Object { .Length -gt 0 }
The $_ is silently removed or mangled, producing syntax errors or empty output.
Similarly, $env:PATH, $c = 1, $matches, etc. are all affected.
Expected Behaviour
$ characters should be passed through literally to the shell when the configured shell is PowerShell. The current escaping/interpolation logic likely assumes bash/sh where $VAR expansion is relevant, but PowerShell uses $ as its native variable sigil.
Current Workaround
Writing commands to .ps1 script files first, then executing the script via exec. This works reliably but adds friction for simple one-liners.
Impact
This affects essentially every session that touches PowerShell beyond trivial commands (ls, cat, cd). In our deployment we've logged ~140+ occurrences of this workaround being needed.
Environment
- OS: Windows 10 (10.0.19045)
- Shell: powershell
- Node: v24.6.0