Title: Splatting with arrays containing `--%`, the stop-parsing token, doesn't work if the array element containing that token happens to be `[psobject]`-wrapped · Issue #21260 · PowerShell/PowerShell · GitHub
Open Graph Title: Splatting with arrays containing `--%`, the stop-parsing token, doesn't work if the array element containing that token happens to be `[psobject]`-wrapped · Issue #21260 · PowerShell/PowerShell
X Title: Splatting with arrays containing `--%`, the stop-parsing token, doesn't work if the array element containing that token happens to be `[psobject]`-wrapped · Issue #21260 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/21260
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Splatting with arrays containing `--%`, the stop-parsing token, doesn't work if the array element containing that token happens to be `[psobject]`-wrapped","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nNote:\r\n\r\n* This is an unusual scenario, because `--%` is usually only used with _external (native) programs_.\r\n\r\n* However, PowerShell functions or scripts can meaningfully leverage it by using _splatting_ to _relay_ positional arguments starting with `--%` to external programs:\r\n\r\n* This is yet another manifestation of #5579\r\n\r\n```powershell\r\n# On Windows\r\n\r\nfunction foo {\r\n $ownArg = $args[0]\r\n # Using Select-Object causes the problem, due to [psobject]-wrapping the elements.\r\n $passThruArgs = $args | Select-Object -Skip 1\r\n # To fix the problem, uncomment the next line.\r\n # $passThruArgs[0] = $passThruArgs[0].psobject.BaseObject\r\n cmd /c echo @passThruArgs\r\n}\r\n\r\nfoo own --% pass these args through, even with broken syntax such as \"a or b)\r\n```\r\n\r\n### Expected behavior\r\n\r\n```console\r\npass these args through, even with broken syntax such as \"a or b)\r\n```\r\n\r\nThat 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.\r\n\r\n### Actual behavior\r\n\r\n```console\r\n--% \"pass these args through, even with broken syntax such as \"a or b)\"\r\n```\r\n\r\nThat 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 `\"...\"`.\r\n\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPowerShell 7.5.0-preview.1\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2024-02-22T00:02:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/21260/PowerShell/issues/21260"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5a848862-8cbc-7d4c-42af-62e09b05550b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B528:1F57A1:13614F:1991F3:6A5B177F |
| html-safe-nonce | 0a2e4a4c5ec9ff12864badcee98cea4c08c86fb5fcbee033d4267a1f4c799373 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTI4OjFGNTdBMToxMzYxNEY6MTk5MUYzOjZBNUIxNzdGIiwidmlzaXRvcl9pZCI6IjM3NTQ0ODM0NTQ5OTk5OTIxOTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | af7ada412489aa55b6dccde933f09ee7e0cfd0b160af149a45d2fb2150998ba7 |
| hovercard-subject-tag | issue:2147917054 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/21260/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dc8d9f87f26360ca414b03eaaac54c611cf08ea8a9a6b003b8742a3dd82274f4/PowerShell/PowerShell/issues/21260 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dc8d9f87f26360ca414b03eaaac54c611cf08ea8a9a6b003b8742a3dd82274f4/PowerShell/PowerShell/issues/21260 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width