Address Set-Location/Get-Item Issue With ?/* Characters#12294
Address Set-Location/Get-Item Issue With ?/* Characters#12294NoMoreFood wants to merge 4 commits intoPowerShell:masterfrom
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
TravisEz13
left a comment
There was a problem hiding this comment.
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 |
NoMoreFood
left a comment
There was a problem hiding this comment.
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,.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.