Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should always be treated as a *literal* path #13136

Closed
mklement0 opened this issue Jul 8, 2020 · 16 comments
Labels
Area-FileSystem-Provider specific to the FileSystem provider Committee-Reviewed PS-Committee has reviewed this and made a decision Issue-Enhancement the issue is more of a feature request than a bug Resolution-No Activity Issue has had no activity for 6 months or more WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module

Comments

@mklement0
Copy link
Contributor

mklement0 commented Jul 8, 2020

Note:

Summary of the new feature/enhancement

When 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.

  • 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.

  • 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.

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).


Once the change is implemented, the following tests - which currently fail - should succeed:

$null = New-Item 'file1', 'file[1]'

$targetRelative = 'file[1]'
$targetAbsolute = Join-Path $pwd.providerpath 'file[1]'

(New-Item -Type SymbolicLink fileL -Target $targetRelative).Target | Should -Be $targetRelative
(New-Item -Force -Type SymbolicLink fileL -Target $targetAbsolute).Target | Should -Be $targetAbsolute

The tests currently fail, because file[1] is interpreted as a wildcard pattern that happens to match file1.

@mklement0 mklement0 added the Issue-Enhancement the issue is more of a feature request than a bug label Jul 8, 2020
@mklement0 mklement0 changed the title New-Item: When creating symbolic links (symlinks) / reparse points, always interpret the -Target path as a *literal* path New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should be treated as a *literal* path Jul 8, 2020
@iSazonov iSazonov added WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc. Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Jul 10, 2020
@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Jul 15, 2020

@PowerShell/powershell-committee agrees that -Target should have always have been a literal path and this is a bucket 3 breaking change

@SteveL-MSFT SteveL-MSFT added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Jul 15, 2020
@JamesWTruher
Copy link
Member

could you add a couple of actual examples please?

@iSazonov
Copy link
Collaborator

@mklement0 Please update title and description to follow "always".

@mklement0 mklement0 changed the title New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should be treated as a *literal* path New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should always be treated as a *literal* path Jul 16, 2020
@mklement0
Copy link
Contributor Author

@iSazonov, done.
@JamesWTruher, I've added Pester tests to the bottom of the OP.

@iSazonov
Copy link
Collaborator

@mklement0 Are you ready to pull the fix? I'd review...

@mklement0
Copy link
Contributor Author

@iSazonov, given that you're already familiar with that area of the code, how about we swap these roles? 😁

@iSazonov
Copy link
Collaborator

@mklement0 In the case we can not merge :-( without MSFT team but they are busy.

@mklement0
Copy link
Contributor Author

Since I'm not familiar with the procedures: Are you saying that if you create the PR yourself, you cannot also merge it, but if I create it, you could? Wouldn't that mean that #13082 is also blocked until a maintainer has time to review and merge?

@iSazonov
Copy link
Collaborator

Yes, I can not merge my commit without anybody approve it. (It is good policy.) So I ask community members to pull PRs so that I can review and merge a community contribution if it is simple and well covered by tests without waiting MSFT experts.

@iSazonov iSazonov added Area-FileSystem-Provider specific to the FileSystem provider WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module and removed WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc. labels Dec 3, 2021
@huoyaoyuan
Copy link

@iSazonov What's the status of this now? It's blocking people again and again.

@iSazonov
Copy link
Collaborator

@huoyaoyuan We haven't enough contributors and code reviewers in the project.

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

2 similar comments
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Nov 16, 2023
@huoyaoyuan
Copy link

We haven't enough contributors and code reviewers in the project.

I can try to contribute if there is a clear decision.

Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-FileSystem-Provider specific to the FileSystem provider Committee-Reviewed PS-Committee has reviewed this and made a decision Issue-Enhancement the issue is more of a feature request than a bug Resolution-No Activity Issue has had no activity for 6 months or more WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants