Skip to content

Experimental feature PSNativeCommandArgumentPassing breaks cmd /c calls with embedded double quotes #15239

Closed

Description

See also: #15250, #15261, #15276 - see overview in #15143.

The new-in-preview.5 PSNativeCommandArgumentPassing experimental feature aims to fix the longstanding problem with passing arguments to external programs, notably arguments with embedded " chars. and empty-string arguments. (see #1995 (comment) for a summary of the previously required workarounds; #14692 is the PR that implemented the experimental feature).

The experimental feature:

As explained in #14747 (comment), the old, broken behavior must be retained in this very specific scenario, because cmd.exe actually requires this broken behavior.

Steps to reproduce

Note: To see the problem, you must use PowerShell Core 7.2.0-preview.5, with experimental feature PSNativeCommandArgumentPassing enabled and preference variable $PSNativeCommandArgumentPassing set to 'Standard' (the default).

cmd /c 'echo "3"'
cmd /c "echo `"$(1+2)`""

(Note that cmd.exe's internal echo command retains double-quoting as passed on the command line.)

Expected behavior

"3"
"3"

This is the old - and in this exceptional case correct - behavior.

Actual behavior

\"3\"
\"3\"

Embedded " chars. were passed escaped as \" - while this is generally the right thing to do, it isn't when calling cmd /c or cmd /k with a command line passed as a single string.

Environment data

PowerShell Core 7.2.0-preview.5

Activity

  1. added
    Issue-BugIssue has been identified as a bug in the product
    and removed
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Jun 9, 2021
  2. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  3. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  4. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  5. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

Metadata

Metadata

Labels

Issue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions