Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Splatting with arrays containing --%, the stop-parsing token, doesn't work if the array element containing that token happens to be [psobject]-wrapped #21260

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Prerequisites

Steps to reproduce

Note:

# On Windows

function foo {
  $ownArg = $args[0]
  # Using Select-Object causes the problem, due to [psobject]-wrapping the elements.
  $passThruArgs = $args | Select-Object -Skip 1
  # To fix the problem, uncomment the next line.
  # $passThruArgs[0] = $passThruArgs[0].psobject.BaseObject
  cmd /c echo @passThruArgs
}

foo own --% pass these args through, even with broken syntax such as "a or b)

Expected behavior

pass these args through, even with broken syntax such as "a or b)

That is, --% in the array used for splatting should result in the space-concatenated, verbatim list of the remaining arguments to be copied verbatim to the process command line behind the scenes.

Actual behavior

--% "pass these args through, even with broken syntax such as "a or b)"

That is, due to the - invisible and usually inconsequential - [psobject] wrappers created by Select-Object, splatting didn't recognize --% as the stop-parsing token, unexpectedly causing it to be passed on as an argument itself, and the remaining arguments to be enclosed in "...".

Error details

No response

Environment data

PowerShell 7.5.0-preview.1

Visuals

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.

    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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.