Title: PowerShell should support passing verbatim args · Issue #12975 · PowerShell/PowerShell · GitHub
Open Graph Title: PowerShell should support passing verbatim args · Issue #12975 · PowerShell/PowerShell
X Title: PowerShell should support passing verbatim args · Issue #12975 · PowerShell/PowerShell
Description: Following a conversation with Steve Lee (@SteveL-MSFT) where he confirmed I am not (entirely) insane 😜 PowerShell currently makes if VERY difficult to Specify that an arbitrary set of command-line args gets passed to an exe, verbatim Tha...
Open Graph Description: Following a conversation with Steve Lee (@SteveL-MSFT) where he confirmed I am not (entirely) insane 😜 PowerShell currently makes if VERY difficult to Specify that an arbitrary set of command-line ...
X Description: Following a conversation with Steve Lee (@SteveL-MSFT) where he confirmed I am not (entirely) insane 😜 PowerShell currently makes if VERY difficult to Specify that an arbitrary set of command-line ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/12975
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PowerShell should support passing verbatim args","articleBody":"Following a conversation with @SteveL-MSFT where he confirmed I am not (entirely) insane 😜\r\n\r\nPowerShell currently makes if VERY difficult to \r\n\r\n1. Specify that an arbitrary set of command-line args gets passed to an exe, verbatim\r\n2. That the same command-line also supports PowerShell command chaining, etc.\r\n\r\nFor example, trying to pass a Linux command-line `cd / && ls . | cowsay` to `wsl` in PowerShell 7+:\r\n```powershell\r\nwsl cd / && ls .\r\n```\r\nExpected: Directory listing of the root of the users' default Linux distro\r\nActual: Error reporting that cowsay is not a recognized command:\r\n\r\n\r\n> Note: to perform the above command, you'll need to [enable WSL and a Linux distro](https://docs.microsoft.com/en-us/windows/wsl/install-win10). Within your default distro, you'll also need to install `cowsay` via your distro's package manager. For Ubuntu and Debian, you can do this via `sudo apt install cowsay`\r\n\r\nAs can be seen from the syntax color highlighting, PowerShell is parsing `&&` as a PowerShell command continuation, not as a part of the command to be passed to `wsl`.\r\n\r\nSo, how about wrapping the args in quotes?\r\n\r\n\r\nDoesn't work because that would make `arg[1]` `'cd / && ls . | cowsay'` which wouldn't make sense to bash.\r\n\r\n@SteveL-MSFT recommended prefixing the command-line args with `--%` to indicate that PowerShell should pass the remaining command-line verbatim. Alas, no joy here - notice the syntax highlighting which indicates that the parser thinks the `&&` is a PowerShell command which, in this case, it is not!\r\n\r\n\r\nBoo! 😟\r\n\r\nOkay, so how about escaping the `&&` with a ````` (backtick)?\r\n\r\n\r\nOh! PowerShell thinks that I meant to spawn the remaining command as a job. NOPE!\r\n\r\nHow about escaping each `&`?\r\n\r\n\r\nCloser!\r\n\r\nNow, how about also escaping the pipe operator:\r\n\r\n\r\nHUZZAH! 🙌\r\n\r\nEscaping many symbols in lengthy command-lines could get tedious pretty quickly, especially when pasting more lengthy & complex bash command-lines into WSL, or complex page splits into `wt` (Windows Terminal):\r\n\r\n\r\nWhile `--%` may be useful (when fixed) in some cases to pass the remainder of __this__ command-line to the tool being executed, commands couldn't be chained.\r\n\r\nSo, ideally, PowerShell should (also) provide a way of escaping a specific portion of a command-line to the preceding tool, but then continue treating the remaining command-line as PowerShell script.\r\n\r\nPerhaps enclosing the command-line segment in some of the following delimiters would work?\r\n\r\n* Pointy-braces: `\u003c` ... `>`, e.g. `wsl \u003ccd / && ls . | cowsay>`\r\n* Square-braces: `[` ... `]`, e.g. `wsl [cd / && ls . | cowsay]`\r\n* Curly-braces: `{` ... `}`, e.g. `wsl {cd / && ls . | cowsay}`\r\n* Double-backticks\r\n* Arrow: `\u003c--` ... `--\u003c\u003c\u003c` , e.g. `wsl \u003c-- cd / && ls . | cowsay --\u003c\u003c\u003c` 😜\r\n\r\n... but will leave the choice of the enclosing delimiters to the language designers 😁","author":{"url":"https://github.com/bitcrazed","@type":"Person","name":"bitcrazed"},"datePublished":"2020-06-17T00:07:02Z","url":"https://github.com/PowerShell/PowerShell/issues/12975"}
| 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:a66cad15-97d2-4efe-8e3d-0e78b82f4db4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C67A:A067:2629F35:3527781:6AFD42FD |
| html-safe-nonce | 923bb30eb098aa4f52b238af8f49fd5d59b0ba36e0280c4d74411b76526d96c9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjdBOkEwNjc6MjYyOUYzNTozNTI3NzgxOjZBRkQ0MkZEIiwidmlzaXRvcl9pZCI6Ijg2OTg4MDA1NjMzNDA3NDYyMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 17b606fe221c6328a0d69c01939a0344b46d1f40921978b15854304ca74ed93c |
| hovercard-subject-tag | issue:640046798 |
| 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/12975/issue_layout |
| twitter:image | https://opengraph.githubassets.com/87ac4136da594ec5f85089c58c31f2a36e4aaf2e2e2dbace54f8c6cf10edc1b5/PowerShell/PowerShell/issues/12975 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/87ac4136da594ec5f85089c58c31f2a36e4aaf2e2e2dbace54f8c6cf10edc1b5/PowerShell/PowerShell/issues/12975 |
| og:image:alt | Following a conversation with Steve Lee (@SteveL-MSFT) where he confirmed I am not (entirely) insane 😜 PowerShell currently makes if VERY difficult to Specify that an arbitrary set of command-line ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bitcrazed |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| 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 | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width