Title: New-Item Type SymbolicLink on Unix-like platforms unexpectedly converts relative target paths to absolute one · Issue #15233 · PowerShell/PowerShell · GitHub
Open Graph Title: New-Item Type SymbolicLink on Unix-like platforms unexpectedly converts relative target paths to absolute one · Issue #15233 · PowerShell/PowerShell
X Title: New-Item Type SymbolicLink on Unix-like platforms unexpectedly converts relative target paths to absolute one · Issue #15233 · PowerShell/PowerShell
Description: PR #12797 tried to implement support for relative target paths for symbolic links (symlinks). On Windows, this now works properly. On Unix-like platforms, a relative input path is still unexpectedly converted to a full path and stored as...
Open Graph Description: PR #12797 tried to implement support for relative target paths for symbolic links (symlinks). On Windows, this now works properly. On Unix-like platforms, a relative input path is still unexpectedl...
X Description: PR #12797 tried to implement support for relative target paths for symbolic links (symlinks). On Windows, this now works properly. On Unix-like platforms, a relative input path is still unexpectedl...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/15233
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"New-Item Type SymbolicLink on Unix-like platforms unexpectedly converts relative target paths to absolute one","articleBody":"PR https://github.com/PowerShell/PowerShell/pull/12797 tried to implement support for _relative_ target paths for symbolic links (symlinks).\r\n\r\n* On Windows, this now works properly.\r\n\r\n* On Unix-like platforms, a relative input path is still unexpectedly converted to a full path and stored as such in the symlink.\r\n\r\n## Steps to reproduce\r\n\r\nNote: Run on macOS and/or Linux (the test succeeds on Windows).\r\n\r\n```powershell\r\nPush-Location -ea Stop ($tmpDir = (New-Item -Type Directory -Force (Join-Path Temp:/ $PID)).FullName)\r\n\r\n# Create a file to serve as the symlink target.\r\n$null = New-Item -Force file\r\n\r\n# Determine the native file-system path separator, as well as the one \r\n# *not* native to the platform.\r\n$sep = [IO.Path]::DirectorySeparatorChar\r\n$otherSep = $sep -eq '/' ? '\\' : '/'\r\n\r\n# To also test path-separator normalization, we use the non-native separator.\r\n$null = New-Item -Force -Type SymbolicLink fileL -Target \".${otherSep}file\"\r\n\r\n# The symlink's target should be a relative path that uses the platform-appropriate path separator.\r\n(Get-Item fileL).Target | Should -Be \".${sep}file\"\r\n\r\n# Clean up.\r\nPop-Location; Remove-Item $tmpDir -Recurse\r\n```\r\n\r\n## Expected behavior\r\n\r\nThe test should succeed.\r\n\r\n## Actual behavior\r\n\r\nThe test fails, because the relative input path is unexpectedly first resolved to a full path before the symlink is defined:\r\n\r\n```none\r\nInvalidResult: Expected strings to be the same, but they were different. \r\nExpected length: 6 Actual length: 14 Strings differ at index 0. \r\nExpected: './file' But was: '/tmp/2802/file'\r\n```\r\n\r\n## Environment data\r\n\r\n```none\r\nPowerShell Core 7.2.0-preview.4\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2021-04-14T17:12:51Z","url":"https://github.com/PowerShell/PowerShell/issues/15233"}
| 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:9af5bd34-c00c-9273-9d48-f1c929386ad7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD84:3A7D16:26553A8:35B1F27:6AFD51E6 |
| html-safe-nonce | 8299c35a19e88c604804fc49eef6a3d687dd02ff53542994a0dab66e3b658e30 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDg0OjNBN0QxNjoyNjU1M0E4OjM1QjFGMjc6NkFGRDUxRTYiLCJ2aXNpdG9yX2lkIjoiNTU4OTc1NDQ4ODQ3MTUwNzQzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 83a31ae7228d7ba93bbac5aaf8c842f69093c06dd4286a0a9078e06f200e84d2 |
| hovercard-subject-tag | issue:858096510 |
| 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/15233/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bb450374e4a92ec92f4ef4b50182cd39ed2d39b41ca277ee8783717d2923d473/PowerShell/PowerShell/issues/15233 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bb450374e4a92ec92f4ef4b50182cd39ed2d39b41ca277ee8783717d2923d473/PowerShell/PowerShell/issues/15233 |
| og:image:alt | PR #12797 tried to implement support for relative target paths for symbolic links (symlinks). On Windows, this now works properly. On Unix-like platforms, a relative input path is still unexpectedl... |
| 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