Title: On Windows, a directory symlink doesn't behave a like a directory with Get-ChildItem if its target path is a relative path that starts directly with a name · Issue #15161 · PowerShell/PowerShell · GitHub
Open Graph Title: On Windows, a directory symlink doesn't behave a like a directory with Get-ChildItem if its target path is a relative path that starts directly with a name · Issue #15161 · PowerShell/PowerShell
X Title: On Windows, a directory symlink doesn't behave a like a directory with Get-ChildItem if its target path is a relative path that starts directly with a name · Issue #15161 · PowerShell/PowerShell
Description: Note: This is ultimately a duplicate of #15235 PR #8783 brought the ability to use relative paths as symlink targets on Windows. However, if the target is a directory and the relative path starts with / is just a name (rather than starti...
Open Graph Description: Note: This is ultimately a duplicate of #15235 PR #8783 brought the ability to use relative paths as symlink targets on Windows. However, if the target is a directory and the relative path starts w...
X Description: Note: This is ultimately a duplicate of #15235 PR #8783 brought the ability to use relative paths as symlink targets on Windows. However, if the target is a directory and the relative path starts w...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/15161
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"On Windows, a directory symlink doesn't behave a like a directory with Get-ChildItem if its target path is a relative path that starts directly with a name","articleBody":"Note: This is ultimately a duplicate of #15235\r\n\r\n---\r\n\r\nPR #8783 brought the ability to use _relative_ paths as symlink targets _on Windows_.\r\n\r\nHowever, if the target is a _directory_ and the relative path starts with / is just a _name_ (rather than starting with `.\\`), the resulting symlink doesn't behave like a directory with `Get-ChildItem`.\r\n\r\nNote that on _Unix_, as of PowerShell Core 7.2.0-preview.4, use of relative target paths is still fundamentally unsupported - see #15233\r\n\r\n## Steps to reproduce\r\n\r\nRun on Windows:\r\n\r\n```powershell\r\n# Switch to a temporary directory.\r\nPush-Location -ea Stop ($tmpDir = (New-Item -Type Directory -Force (Join-Path Temp:/ $PID)).FullName)\r\n\r\n# Create a dir. to serve as the target, with a single text file in it.\r\n$null = New-Item -Type Directory target -Force\r\n'hi' > target/t.txt\r\n\r\n# Define two links: \r\n# * one that targets 'target' - by name only.\r\n# * one that targets '.\\target' - explicit reference to the current dir.\r\n$null = New-Item -Type SymbolicLink link1 -Target target -Force\r\n$null = New-Item -Type SymbolicLink link2 -Target .\\target -Force\r\n\r\n# Now compare the Get-ChildItem behavior of these two links, which\r\n# *should* be the same.\r\nGet-ChildItem link1\r\nGet-ChildItem link2\r\n\r\nPop-Location; Remove-Item -lp $tmpDir -Recurse\r\n```\r\n\r\n## Expected behavior\r\n\r\nWith the exception of the directory path in the grouping header, the commands should produce the same output and show the _content_ of the target dir:\r\n\r\n```none\r\n Directory: C:\\Users\\jdoe\\AppData\\Local\\Temp\\8748\\link1\r\n\r\nMode LastWriteTime Length Name\r\n---- ------------- ------ ----\r\n-a--- 4/5/2021 3:30 PM 4 t.txt\r\n\r\n Directory: C:\\Users\\jdoe\\AppData\\Local\\Temp\\8748\\link2\r\n\r\nMode LastWriteTime Length Name\r\n---- ------------- ------ ----\r\n-a--- 4/5/2021 3:30 PM 4 t.txt\r\n```\r\n\r\n## Actual behavior\r\n\r\n```none\r\n Directory: C:\\Users\\jdoe\\AppData\\Local\\Temp\\8748\r\n\r\nMode LastWriteTime Length Name\r\n---- ------------- ------ ----\r\nla--- 4/5/2021 3:30 PM 0 link1 -> target\r\n\r\n Directory: C:\\Users\\jdoe\\AppData\\Local\\Temp\\8748\\link2\r\n\r\nMode LastWriteTime Length Name\r\n---- ------------- ------ ----\r\n-a--- 4/5/2021 3:30 PM 4 t.txt\r\n```\r\n\r\nNote how `link1` present as if it were a _flle_, as if you had called `Get-Item` rather than `Get-ChildItem` on it.\r\n\r\nInterestingly, `cmd.exe`'s `dir` shows analogous behavior, and additionally fails with `dir link1\\t.txt`, which PowerShell handles correctly.\r\n\r\n## Environment data\r\n\r\n```none\r\nPowerShell Core v7.2.0-preview.4 (.NET 6.0.0-preview.2.21154.6) on Microsoft Windows 10 Pro (64-bit; Version 20H2, OS Build: 19042.867)\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2021-04-05T19:34:41Z","url":"https://github.com/PowerShell/PowerShell/issues/15161"}
| 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:32a1dda7-73fe-d924-aa2d-28a4a9005c44 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFBE:A7B59:1CB29B:27331B:6AFD506D |
| html-safe-nonce | 53c757daed143d05207e7e6e10dd0166f025dbc2b9825cb0c06636c9b323359e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkJFOkE3QjU5OjFDQjI5QjoyNzMzMUI6NkFGRDUwNkQiLCJ2aXNpdG9yX2lkIjoiNjk1NTQzOTk0OTg0MzYxNTg1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f1ceedc7ae3a94d0f51f7c309df9a49e54fbcac54a5db01c472426a9d0b4dcec |
| hovercard-subject-tag | issue:850607220 |
| 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/15161/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4149127965a4c7b9c8dc2d5f4b5522f285e9deff1ab85c1be3dcfecb1ad4acd4/PowerShell/PowerShell/issues/15161 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4149127965a4c7b9c8dc2d5f4b5522f285e9deff1ab85c1be3dcfecb1ad4acd4/PowerShell/PowerShell/issues/15161 |
| og:image:alt | Note: This is ultimately a duplicate of #15235 PR #8783 brought the ability to use relative paths as symlink targets on Windows. However, if the target is a directory and the relative path starts w... |
| 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