Title: Make $PSScriptRoot and $PSCommandPath also reflect the true filesystem locations for scripts invoked via symlinks · Issue #11054 · PowerShell/PowerShell · GitHub
Open Graph Title: Make $PSScriptRoot and $PSCommandPath also reflect the true filesystem locations for scripts invoked via symlinks · Issue #11054 · PowerShell/PowerShell
X Title: Make $PSScriptRoot and $PSCommandPath also reflect the true filesystem locations for scripts invoked via symlinks · Issue #11054 · PowerShell/PowerShell
Description: Summary of the new feature/enhancement Symlinks (symbolic links) are a staple of the Unix world and are becoming increasingly common on Windows too. For scripts invoked via symlinks, the "reflective" variables that contain the running sc...
Open Graph Description: Summary of the new feature/enhancement Symlinks (symbolic links) are a staple of the Unix world and are becoming increasingly common on Windows too. For scripts invoked via symlinks, the "reflectiv...
X Description: Summary of the new feature/enhancement Symlinks (symbolic links) are a staple of the Unix world and are becoming increasingly common on Windows too. For scripts invoked via symlinks, the "refl...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11054
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make $PSScriptRoot and $PSCommandPath also reflect the true filesystem locations for scripts invoked via symlinks","articleBody":"# Summary of the new feature/enhancement\r\n\r\nSymlinks (symbolic links) are a staple of the Unix world and are becoming increasingly common on Windows too.\r\n\r\nFor scripts invoked via symlinks, the \"reflective\" variables that contain the running script's location (directory, `$PSScriptRoot`) and `$PSCommandPath` currently reflect only the _link_'s information, not (also) the underlying file's information.\r\n\r\n(Reporting the _link_'s information is consistent with the behavior of POSIX-like shells such as Bash, via `$0` and `$BASH_SOURCE`).\r\n\r\nWhile you can _manually_ investigate the paths contained in these variables to find the true script location and file name, it would be nice to have this information _automatically_ available.\r\n\r\nAs an aside: Even manual investigation is currently nontrivial - see #10640\r\n\r\n# Proposed technical implementation details (optional)\r\n\r\nOne option that doesn't require introducing _new_ automatic variables (which is always problematic) is to add a `NoteProperty` member name, say, `.Target` to the `$PSScriptRoot` and `$PSCommandPath` variables that reflects the underlying script file's true directory and full filename, respectively.\r\n\r\nThat way, you could use `$PSCommandPath.Target` to get the running script's true full path, for instance.\r\n\r\nWhile somewhat obscure, this follows the pattern of the `NoteProperty` members the `$PROFILE` automatic variable is decorated with, which reflect the paths of the various profile types and scopes.\r\n\r\n_Documenting_ these non-obvious properties clearly should be sufficient, however.\r\n\r\n\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-11-12T22:39:19Z","url":"https://github.com/PowerShell/PowerShell/issues/11054"}
| 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:4e73ab85-256a-be19-db7a-2c8367778d11 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C242:19F6D5:76985:A8441:6AFDA9B0 |
| html-safe-nonce | 11dd13b33d86c8508a8e8ed6845af99ec4be10c0abbb5795c1c7d3e283c8bd3f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjQyOjE5RjZENTo3Njk4NTpBODQ0MTo2QUZEQTlCMCIsInZpc2l0b3JfaWQiOiIzNzMzNzg3NzEyNzEzMjM4OTYwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 33d427f2ae19099ee628b6819de77976baec8dc94a91abb79f2cae908bb369cf |
| hovercard-subject-tag | issue:521844593 |
| 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/11054/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c7a308b74f99f3a4402815cd97d17972d0364d731cb6493d70d9d9423f7e35c1/PowerShell/PowerShell/issues/11054 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c7a308b74f99f3a4402815cd97d17972d0364d731cb6493d70d9d9423f7e35c1/PowerShell/PowerShell/issues/11054 |
| og:image:alt | Summary of the new feature/enhancement Symlinks (symbolic links) are a staple of the Unix world and are becoming increasingly common on Windows too. For scripts invoked via symlinks, the "reflectiv... |
| 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