Title: New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should always be treated as a *literal* path · Issue #13136 · PowerShell/PowerShell · GitHub
Open Graph Title: New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should always be treated as a *literal* path · Issue #13136 · PowerShell/PowerShell
X Title: New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should always be treated as a *literal* path · Issue #13136 · PowerShell/PowerShell
Description: Note: This is technically a breaking change, but one that to me falls into Bucket 3: Unlikely Grey Area. We've recently made an analogous change to Invoke-WebRequest / Invoke-RestMethod, which now sensibly interpret their -OutFile argume...
Open Graph Description: Note: This is technically a breaking change, but one that to me falls into Bucket 3: Unlikely Grey Area. We've recently made an analogous change to Invoke-WebRequest / Invoke-RestMethod, which now ...
X Description: Note: This is technically a breaking change, but one that to me falls into Bucket 3: Unlikely Grey Area. We've recently made an analogous change to Invoke-WebRequest / Invoke-RestMethod, which ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/13136
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should always be treated as a *literal* path","articleBody":"Note: \r\n\r\n* This is technically a breaking change, but one that to me falls into [Bucket 3: Unlikely Grey Area](https://github.com/PowerShell/PowerShell/blob/master/docs/dev-process/breaking-change-contract.md#bucket-3-unlikely-grey-area).\r\n\r\n* We've recently made an analogous change to `Invoke-WebRequest` / `Invoke-RestMethod`, which now sensibly interpret their `-OutFile` argument invariably as a _literal_ path - see #11701\r\n\r\n * Similar fixes are pending in other contexts: #4726, #9225, #4726.\r\n\r\n## Summary of the new feature/enhancement\r\n\r\nWhen you create a symlink or reparse point, you want to target a _specific, literal_ target path - you're not looking for this path to determined via _wildcard-pattern matching_, which, however, is what currently happens: a `-Target` (`-Value`) argument is (invariably) interpreted as a wildcard pattern. What makes the behavior even less useful is that the pattern must resolve to _exactly one_ path.\r\n\r\n* Interpreting the `-Target` (`-Value`) argument as a wildcard expression means that meant-to-be-literal paths such as `[a].txt` would mistakenly target `a.txt`, if present, for instance.\r\n\r\n* Also, as a potentially unwanted side effect, if the `-Target` (`-Value`) _is_ determined via wildcard resolution, a relative input path (pattern) is invariably resolved to a _full_ path.\r\n\r\n**The sensible behavior is to _always_ treat the `-Target` (`-Value`) argument as a _literal_ path** (and to preserve its relative-vs.-full path status, as specified).\r\n\r\n---\r\n\r\nOnce the change is implemented, the following tests - which currently fail - should succeed:\r\n\r\n```powershell\r\n$null = New-Item 'file1', 'file[1]'\r\n\r\n$targetRelative = 'file[1]'\r\n$targetAbsolute = Join-Path $pwd.providerpath 'file[1]'\r\n\r\n(New-Item -Type SymbolicLink fileL -Target $targetRelative).Target | Should -Be $targetRelative\r\n(New-Item -Force -Type SymbolicLink fileL -Target $targetAbsolute).Target | Should -Be $targetAbsolute\r\n```\r\n\r\nThe tests currently fail, because `file[1]` is interpreted as a wildcard pattern that happens to match `file1`.\r\n\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2020-07-08T18:27:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/13136/PowerShell/issues/13136"}
| 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:bb208220-f0df-e5dc-0058-345c27785c34 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C88E:3FFE0B:10FF96D:186D8B7:6A589E5B |
| html-safe-nonce | 1019a83c8a9fdbc63d13ca1cad5dfcc0a27c5f1d5f83406e06120e9f42bbff65 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODhFOjNGRkUwQjoxMEZGOTZEOjE4NkQ4Qjc6NkE1ODlFNUIiLCJ2aXNpdG9yX2lkIjoiNTQ5NzMxMDQ1NDE5NTE5OTU3OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b02072d9c4e2be61898858d6c39515289b5afb9d7d4fe05482035c05315e1774 |
| hovercard-subject-tag | issue:653506750 |
| 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/13136/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cf375cba96d22d668bb6528a09d37cd851bb6eb8e490a5531b9f0972456b59f6/PowerShell/PowerShell/issues/13136 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cf375cba96d22d668bb6528a09d37cd851bb6eb8e490a5531b9f0972456b59f6/PowerShell/PowerShell/issues/13136 |
| og:image:alt | Note: This is technically a breaking change, but one that to me falls into Bucket 3: Unlikely Grey Area. We've recently made an analogous change to Invoke-WebRequest / Invoke-RestMethod, which now ... |
| 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 | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| 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 | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width