Title: Bypassing translation of PSDrive-based path arguments for external (native) executables is obscure and inadequate (PSNativePSPathResolution) · Issue #13644 · PowerShell/PowerShell · GitHub
Open Graph Title: Bypassing translation of PSDrive-based path arguments for external (native) executables is obscure and inadequate (PSNativePSPathResolution) · Issue #13644 · PowerShell/PowerShell
X Title: Bypassing translation of PSDrive-based path arguments for external (native) executables is obscure and inadequate (PSNativePSPathResolution) · Issue #13644 · PowerShell/PowerShell
Description: Follow-up from #13640. PR #12386 introduced experimental feature PSNativePSPathResolution, which as of (at least) PowerShell Core 7.1.0-preview.7 has become a default feature. Its purpose is to translate PowerShell-drive-based paths to n...
Open Graph Description: Follow-up from #13640. PR #12386 introduced experimental feature PSNativePSPathResolution, which as of (at least) PowerShell Core 7.1.0-preview.7 has become a default feature. Its purpose is to tra...
X Description: Follow-up from #13640. PR #12386 introduced experimental feature PSNativePSPathResolution, which as of (at least) PowerShell Core 7.1.0-preview.7 has become a default feature. Its purpose is to tra...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/13644
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bypassing translation of PSDrive-based path arguments for external (native) executables is obscure and inadequate (PSNativePSPathResolution)","articleBody":"Follow-up from #13640.\r\n\r\nPR #12386 introduced _experimental_ feature `PSNativePSPathResolution`, which as of (at least) PowerShell Core 7.1.0-preview.7 has become a _default_ feature.\r\n\r\nIts purpose is to translate _PowerShell-drive-based_ paths to _native filesystem_ paths, because external executables only understand the latter.\r\n\r\n\r\nWhile this is likely helpful in most cases, there are two problems, both stemming from the fact that **PowerShell cannot know whether a given argument passed to an external program indeed represents a file path**:\r\n\r\n* There must be a way to _bypass_ this translation, in case an argument that happens to _look like_ a PSDrive-based path should be passed as-is.\r\n\r\n * Currently, the only way to bypass the translation is to use _single-quoting_ (e.g, `'temp:foo'` rather than unquoted `temp:foo` or double-quoted `\"temp:foo\"`, but this is problematic for two reasons:\r\n * This distinction is obscure, because the user is likely to conceive of _both_ `'temp:foo'` and `\"temp:foo\"` as literals, which in any other context they are.\r\n * More importantly: it only works for _literal_ arguments, and not for variables and expressions. \r\n\r\n* Even with such a mechanism, however, the problem is that bypassing may only be _situationally_ necessary, depending on what custom PS drives happen to be defined at the time of the external-program call, so **you cannot really anticipate when bypassing is necessary**.\r\n\r\nI see two possible solutions:\r\n\r\n* (a) Roll back the feature, recognizing that it is ultimately too fraught (it hasn't been in any official release yet).\r\n\r\n* (b) Minimize the risk of false positives as follows, but note that their complete elimination isn't possible:\r\n\r\n * Currently, the translation is triggered by any argument with a prefix that looks like a drive specification of a custom PS drive (e.g., `temp:`) _irrespective of what follows_: that is, it doesn't matter whether the path refers to an _existing item_ or even if the path is syntactically correct.\r\n\r\n * There will be **far fewer false positives if the translation is only performed if the argument refers to an _existing file-system path_**; e.g., `temp:foo` should only be translated if a file or directory at `temp:/foo` actually exists.\r\n\r\n * However, this implies:\r\n * Users may be confused when a non-existing path they expected to exist goes untranslated.\r\n * Arguments may by design represent not-yet-extant paths, such as when passing an _output_ file path.\r\n * A bypass mechanism is still needed, one that also supports passing arguments via variables and expressions; though perhaps the need for it will be so rare that the limited `--%` will do.\r\n\r\n\r\n## Steps to reproduce\r\n\r\nThe following is predicated on suggestion (b) above, i.e., only performing translation for _existing_ PSDrive-based paths, and assumes that no file/dir. exists at `temp:/foo`\r\n\r\nOn Unix (use `cmd /c echo` on Windows):\r\n\r\n```powershell\r\n$arg = 'temp:foo'; /bin/echo $arg | Should -be $arg\r\n```\r\n\r\n## Expected behavior\r\n\r\nThe test should pass, because since `temp:foo` doesn't refer to an existing file-system path, it should be passed as-is.\r\n\r\n## Actual behavior\r\n\r\nThe test fails, because the `temp:foo` is translated to `(Get-PSDrive temp).Root + ':/foo'`, even though `temp:/foo` doesn't exist; e.g., on macOS:\r\n\r\n```none\r\nExpected: 'temp:foo' But was: '/var/folde...'\r\n```\r\n\r\n## Environment data\r\n\r\n\r\n```none\r\nPowerShell Core 7.1.0-preview.7\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2020-09-16T18:37:56Z","url":"https://github.com/PowerShell/PowerShell/issues/13644"}
| 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:4ee44c41-35cc-cff7-9365-075cbcd058c2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A6C2:160EF7:AC3BC8:F752CE:6AFDA420 |
| html-safe-nonce | b5fc2dc596654b927b56c08bcfbd60fbbd11de644ca2072aeffe58293a07f19f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkMyOjE2MEVGNzpBQzNCQzg6Rjc1MkNFOjZBRkRBNDIwIiwidmlzaXRvcl9pZCI6Ijc4NzU3OTk3Mjk5NzAxOTM0NDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5aa07a63288c2a1b9dc509cb31a03be2552e4fefb912652868c430b0f38a2265 |
| hovercard-subject-tag | issue:702988618 |
| 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/13644/issue_layout |
| twitter:image | https://opengraph.githubassets.com/000fd02ef3811dd3c487181d7bcc65532408dfb47fae56cf05c6baabd9d8f68e/PowerShell/PowerShell/issues/13644 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/000fd02ef3811dd3c487181d7bcc65532408dfb47fae56cf05c6baabd9d8f68e/PowerShell/PowerShell/issues/13644 |
| og:image:alt | Follow-up from #13640. PR #12386 introduced experimental feature PSNativePSPathResolution, which as of (at least) PowerShell Core 7.1.0-preview.7 has become a default feature. Its purpose is to tra... |
| 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