Title: Make the stop-parsing symbol (--%) work on Unix · Issue #3733 · PowerShell/PowerShell · GitHub
Open Graph Title: Make the stop-parsing symbol (--%) work on Unix · Issue #3733 · PowerShell/PowerShell
X Title: Make the stop-parsing symbol (--%) work on Unix · Issue #3733 · PowerShell/PowerShell
Description: Related: #3734 For the stop-parsing symbol, --%, to work sensibly on Unix: [preferably] either: /bin/sh, the default shell, must be invoked, passing it a command line as a single string via -c. As a - in my view beneficial - side effect,...
Open Graph Description: Related: #3734 For the stop-parsing symbol, --%, to work sensibly on Unix: [preferably] either: /bin/sh, the default shell, must be invoked, passing it a command line as a single string via -c. As ...
X Description: Related: #3734 For the stop-parsing symbol, --%, to work sensibly on Unix: [preferably] either: /bin/sh, the default shell, must be invoked, passing it a command line as a single string via -c. As ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3733
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make the stop-parsing symbol (--%) work on Unix ","articleBody":"\u003csup>Related: #3734 \u003c/sup>\r\n\r\nFor the stop-parsing symbol, `--%`, to work sensibly on Unix:\r\n\r\n* [preferably] _either_: `/bin/sh`, the default shell, must be invoked, passing it a command line as a single string via `-c`. \r\nAs a - in my view beneficial - side effect, `sh` would perform _globbing_ on unquoted tokens.\r\n\r\n* _or_: PowerShell must still first interpret the tokens of the pass-through command line to strip syntactical quoting, in addition to expanding environment/shell variable references. \r\nThat may still run afoul of users' expectation that _globbing_ should be performed.\r\n\r\nNote: On _Windows_ PowerShell can get away with only expanding `%\u003cname>%`-style environment-variable references and then invoking the target utility _without shell involvement_, but that's not an option on Unix, where the shell is expected to perform tokenization up front and pass an _array_ of _literal_ arguments instead (with syntactical elements such as quoting characters removed).\r\n\r\nTo illustrate the problem with the current behavior (run the commands on a _Unix_ platform):\r\n\r\n```powershell\r\n> /bin/echo --% 'hi, mom'\r\n'hi mom' # The enclosing single quotes were treated as *literals*\r\n```\r\n\r\nTrying to pass an `awk` command that from `sh` looks like this: `awk -F\\\" 'BEGIN { print \"hi, mom\" }'`\r\n\r\n```powershell\r\n> awk --% -F\\\" 'BEGIN { print \"hi, mom\" }'\r\n/usr/bin/awk: syntax error at source line 1\r\n context is\r\n\t >>> ' \u003c\u003c\u003c \r\n/usr/bin/awk: bailing out at source line 1\r\n```\r\n\r\nThe array of arguments getting passed to `awk` breaks down as follows (`$\u003cn>` represents the nth positional argument):\r\n\r\n```none\r\n$1=[-F\"]\r\n$2=['BEGIN]\r\n$3=[{]\r\n$4=[print]\r\n$5=[hi, mom]\r\n$6=[}']\r\n```\r\n\r\nAs you can see, the intended argument boundaries weren't respected, and the `'` quoting characters were retained.\r\n\r\nIn fact, there's currently no way to make the above command work with `--%`, because no one is interpreting the quoting and removing the syntactical quoting characters.\r\n\r\nCurrently, only the following truly Byzantine invocation - _not_ involving `--%` - can make the above `awk` command work:\r\n\r\n```powershell\r\n/bin/sh -c \"awk -F\\\\\\`\" 'BEGIN { print \\`\"hi, mom\\`\" }'\"\r\n```\r\n\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on macOS 10.12.4\r\nPowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Ubuntu 16.04.1 LTS\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-05-08T21:31:06Z","url":"https://github.com/PowerShell/PowerShell/issues/3733"}
| 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:94ed501d-5fe1-bd3b-61f2-7774f33ec21e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C7C:2CE118:2710CB3:367D63F:6AFD49BB |
| html-safe-nonce | 55ec6498b3c276c38ff74ee75802f7c800bf574783a50c5dd78a1edd631eb724 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzdDOjJDRTExODoyNzEwQ0IzOjM2N0Q2M0Y6NkFGRDQ5QkIiLCJ2aXNpdG9yX2lkIjoiNzU5NTA2MzM3NDk0MDI2NjgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1542a97cbc74f3b177f4f1fe31edd9d078d496ea6c44a95aa012fbf7ffd8a1c6 |
| hovercard-subject-tag | issue:227180792 |
| 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/3733/issue_layout |
| twitter:image | https://opengraph.githubassets.com/544d5b6ad45a4c3772c68700c635c5d70f6d3a7c652b0491afe20b8a83b259bc/PowerShell/PowerShell/issues/3733 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/544d5b6ad45a4c3772c68700c635c5d70f6d3a7c652b0491afe20b8a83b259bc/PowerShell/PowerShell/issues/3733 |
| og:image:alt | Related: #3734 For the stop-parsing symbol, --%, to work sensibly on Unix: [preferably] either: /bin/sh, the default shell, must be invoked, passing it a command line as a single string via -c. As ... |
| 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 | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| 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 | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width