-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix New-Item to create symlink to relative path target #12797
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
Fix New-Item to create symlink to relative path target #12797
Conversation
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
|
@iSazonov thanks for taking the time to sort this one out. 😊 Quick question -- should / will this affect the |
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
3f947dd to
1c0b49a
Compare
|
@iSazonov Please have a look at the test failure |
|
@mklement0 Could you please help with the MacOs fail? Do you have any thoughts? |
e4d4a1f to
906b318
Compare
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
08bcd9c to
f2b56f7
Compare
|
@iSazonov Thank you for your contribution! |
|
🎉 Handy links: |
|
Is this really how relative path for symlink should behave? This PR changes the behavior of the checks from having Relative path in the symlink target is resolved by filesystem relative to the directory containing the symlink, not relative to CWD of pwsh instance that created it. This should create a working directory symlink: Instead, the check uses path relative to current working directory ( |
|
@MatejKafka Please create new issue if you see an inconsistency. |
|
@MatejKafka, while you are correct, this problem doesn't currently surface, although there are related ones: With respect to creating the symlink, i.e. what target path is stored in its definition:
With respect to validating the existence of the target path on creation:
|
|
@mklement0 Actually, I think it currently surfaces. Because the checks are relative to cwd, they incorrectly detect whether the target is file or directory. Let me try to illustrate it with more examples: (I'll use D:\test as our testing directory to make it clear when I'm talking about absolute paths) Expected: directory symlink to Expected: directory symlink to Expected: file symlink to There are 2 possible correct behaviors I see here:
|
|
Good point, @MatejKafka. As @iSazonov has advised, please create a new issue with your findings. |
PR Summary
Fix #9127.
Before the fix we check an item existence relative to system CWD. After the fix we do the check based on current runspace CWD.
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.