-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Address Set-Location/Get-Item Issue With ?/* Characters #12294
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
base: master
Are you sure you want to change the base?
Conversation
a1cb895
to
8b887f2
Compare
- Adjusted behavior of GetCorrectCasedPath() which attempts to search for the file on the file system in order to normalize its case. Since some file systems support wildcard characters in path names; processing needs to be skipped for these. - Added tests to detect this behavior.
8b887f2
to
02d5492
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This look good. Thanks.
I've requested a coup of changes in the tests to make sure it doesn't regress things now or in the future.
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Show resolved
Hide resolved
@PowerShell/powershell-committee This is a breaking change. Please review. We made a similar change for matching commands. Where we prefer literal matches over wildcard matches. |
@TravisEz13 So I can categorize these correctly in the future, can you educate me as to why this would be considered a breaking change? |
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
@PowerShell/powershell-committee agrees that the current behavior is broken where: set-location -literalpath ? must treat |
- Mark backslash test on MacOS / Linux as 'Pending' vice 'Skipped'. - Use Utils.Separators.StarOrQuestion instead of hard-coded constants.
I'm not sure your change addressed the committee's concern about the location of the change. |
@TravisEz13 Sorry, the day job has distracted me from following through on this and one other PR. I honestly thought the "location of the code change" comment was sort of meant to be rhetorical. The bug itself can be scoped to that helper function: In what scenario would I possibly pass a literal, existing directory path to GetCorrectCasedPath() and it would be acceptable to get back a reference to an existing different directory? The function exists solely to normalize case within a path --- it should NEVER be returning a path to a different file. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
65bee7b
to
7c4a4f9
Compare
- Added failure test for a directory that contains wildcard characters.
7c4a4f9
to
fed014a
Compare
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
Is this ready for merge or are we still waiting for reviews? @TravisEz13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I have resolved these.
Here is the direct call: Then, We need to make sure we didn't break any of these calls. |
I'll let the Provider working group review from here. |
The GetCorrectCasedPath() is not in right place. This would only have to be used in Formatting System and completors. |
@TravisEz13 All of the non-file system paths you reference end up calling a base class version or provider-specific version of NormalizePath() so this change luckily does not affect them. @iSazonov I think that might be splitting hairs to some degree. When somebody does a Set-Location to a specific path, do you want the resultant path at the prompt to be case-accurate or not? I think it might be hard to address all the "what if" sort of cases. Regardless, this PR was authored to address the "bug" within GetCorrectCasedPath() itself so I was hoping not to boil the ocean to get this committed. :-) |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PR Summary
PR Context
This corrects the behavior where Set-Location fails to change directory or changes to an entirely different child directory when the target directory contains characters such as '*'. Similarly, Get-Item also returns errant information.
Resolves: #12299
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.