Repository navigation
Honor -Recurse when Get-ChildItem uses -Name - #28078
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
-Recurse when Get-ChildItem uses -Name
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| { | ||
| // If we're recursing, do some path fixups to match user | ||
| // expectations, but only if the last part is a file and not a directory: | ||
| if (recurse && !path.EndsWith(Path.DirectorySeparatorChar) && !path.EndsWith(Path.AltDirectorySeparatorChar)) |
There was a problem hiding this comment.
The removed code here was actually moved to the NormalizePathForChildItemRecursion method below, with no change at all.
6328501 to
ecb9924
Compare
|
Is your description in "Before the fix:" correct? It seems #9014 is not fixed jet. Also PowerShell Committee conclusion was to reject the change. |
|
This PR will fix #9014: I didn't know that issue and thanks for pointing me to it. I disagree with the WG conclusion. It's hard to imagine someone would depend on this breaking behavior -- they specify Note that |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
This is a breaking change but is not marked as such. It will break patterns i use like renaming a directory to "directory.old", "directory.old.old" etc. It should at least be documented as a breaking change in the release notes. |
PR Summary
Fix
Get-ChildItem -Nameso recursive searches with a wildcard or exact leaf path enumerate matching files in subdirectories. The name-only path now reuses the recursive path normalization already used by regular item enumeration.Add regression coverage for wildcard and exact leaf paths, including searches relative to the current directory and
-Depth 0behavior.PR Context
Get-ChildItem *.md -Recurse -File -Namepreviously expanded*.mdonly in the starting directory. The resolved files are not containers, so recursive name enumeration never received a directory root and did not visit subdirectories.Validation:
Get-ChildItem.Tests.ps1: 31 passedFileSystemProviderExtended.Tests.ps1: 78 passedBefore the fix:
After the fix:
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header