-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Fix New-Item to create symlink to relative path target #12797
Conversation
@iSazonov thanks for taking the time to sort this one out. 😊 Quick question -- should / will this affect the |
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
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
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.