Skip to content

exec tool mangles PowerShell $ syntax on Windows (dollar sign interpolation) #16821

@Stache73

Description

@Stache73

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions