Title: Stop-parsing token is broken · Issue #18664 · PowerShell/PowerShell · GitHub
Open Graph Title: Stop-parsing token is broken · Issue #18664 · PowerShell/PowerShell
X Title: Stop-parsing token is broken · Issue #18664 · 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/18664
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stop-parsing token is broken","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://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nThis was previously reported in #15261, which was inappropriately closed as by-design.\r\n\r\nThe purpose of `--%` (which only makes sense on _Windows_) is to copy the remainder of the command line _verbatim_ to the process command line constructed behind the scenes, so as to provide a way to explicitly control the double-quoting for target executables that have non-standard quoting requirements.\r\n\r\nAs such, it should _not_ be affected by the effective value of `$PSNativeCommandArgumentPassing`\r\n\r\n(Note: It is debatable how arguments that come _before_ `--%` on a given command line should be handled; for backward compatibility I think it would make the most sense to process them as if `'Legacy'` were in effect; in other words: `--%` would be an _implicit, command-scoped_ opt-in to `$PSNativeCommandArgumentPassing = 'Legacy'`).\r\n\r\nHowever, as of v7.3.0 it _is_, and the behavior is _broken_ by default (the only way to make it work again is with `$PSNativeCommandArgumentPassing = 'Legacy'`, which should _not_ be necessary).\r\n\r\n```powershell\r\n# Preparation: Create an executable that echoes the raw command line, as `.\\echoCmdLine.exe`\r\n# Note: Must call via *Windows PowerShell*\r\npowershell -NoProfile {\r\n Add-Type -OutputType ConsoleApplication -OutputAssembly ./echoCmdLine.exe -TypeDefinition @'\r\n using System;\r\n static class ConsoleApp {\r\n static int Main(string[] args) {\r\n Console.WriteLine(Environment.CommandLine);\r\n return 0;\r\n }\r\n }\r\n'@\r\n}\r\n\r\n# Set $PSNativeCommandArgumentPassing to something *other* than 'Legacy'\r\n$PSNativeCommandArgumentPassing = 'Windows' # (the default on Windows)\r\n\r\n# Using --%, pass *verbatim* `/p:Category=\"CI,Nightly\"` on the process command line.\r\n./echoCmdLine --% /p:Category=\"CI,Nightly\"\r\n```\r\n\r\n\r\n\r\n### Expected behavior\r\n\r\n```console\r\n\"C:\\Users\\jdoe\\echoCmdLine.exe\" /p:Category=\"CI,Nightly\"\r\n```\r\n\r\nThat is, the part of the original command line after `--%` should be copied _as-is_ to the process command line.\r\n\r\nThat is how it has worked since v3 (when `--%` was introduced) and should continue to work, irrespective of the value of `$PSNativeCommandArgumentPassing = 'Legacy'`, in both PowerShell editions.\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\n\"C:\\Users\\jdoe\\echoCmdLine.exe\" \"/p:Category=\\\"CI,Nightly\\\"\"\r\n```\r\n\r\nNote how the argument was inappropriately enclosed in `\"...\"`, with embedded `\"` escaped as `\\\"`.\r\n\r\nThat is, the `'Standard'` behavior was inappropriately used (although `cmd.exe`-style environment variables, e.g. `%OS%`, do still get expanded).\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 Core 7.3.0 on Windows\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":"2022-11-25T16:59:45Z","url":"https://github.com/PowerShell/PowerShell/issues/18664"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:5cd8e00b-b7f8-43b7-977b-e5e70629888a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87E2:34A55:E07F6B:141D9EE:6AFDA3A4 |
| html-safe-nonce | 5fd5a92b90b630aca98bb45470fe2a7f5ba9d5cb548eb899e47aa8bda5f2f5f2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0UyOjM0QTU1OkUwN0Y2QjoxNDFEOUVFOjZBRkRBM0E0IiwidmlzaXRvcl9pZCI6IjgwMDE0NjQyMzY3NTg2Mzk1MjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8641e91499d37dbd15c974d44ba7fbf6894ae90eb4ff94acca0814a5457dae3b |
| hovercard-subject-tag | issue:1464770622 |
| 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/18664/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d77f9fb2cf41be393ba531e14aea54fc546c0332396ed77039c63a427e4047f7/PowerShell/PowerShell/issues/18664 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d77f9fb2cf41be393ba531e14aea54fc546c0332396ed77039c63a427e4047f7/PowerShell/PowerShell/issues/18664 |
| 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 | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| 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 | 0ddf53eb35c87f1f8df13dbf75c3bdadbfc6e969 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width