Fix Get-ChildItem -Path with wildcard char (#9257)

Unescape non-literal, non-glob path before existence checking.
This commit is contained in:
kwkam
2019-05-31 10:14:39 -07:00
committed by Dongbo Wang
parent 259c4dd3f2
commit f0133bed8e
2 changed files with 18 additions and 2 deletions
@@ -1478,7 +1478,7 @@ namespace System.Management.Automation
string originalPath = path;
path =
Globber.GetProviderPath(
path,
context.SuppressWildcardExpansion ? path : WildcardPattern.Unescape(path),
context,
out provider,
out drive);
@@ -2441,7 +2441,7 @@ namespace System.Management.Automation
string providerPath =
Globber.GetProviderPath(
path,
context.SuppressWildcardExpansion ? path : WildcardPattern.Unescape(path),
context,
out provider,
out drive);
@@ -196,6 +196,22 @@ Describe "Get-ChildItem" -Tags "CI" {
}
}
Describe "Get-ChildItem with special path" -Tags "CI" {
BeforeAll {
$bracketDirName = "Test[Dir]"
$bracketDir = "Test``[Dir``]"
$bracketPath = Join-Path $TestDrive $bracketDir
$null = New-Item -Path $TestDrive -Name $bracketDirName -ItemType Directory -Force
}
It "Should list files in directory with name containing bracket char" {
$null = New-Item -Path $bracketPath -Name file1.txt -ItemType File
$null = New-Item -Path $bracketPath -Name file2.txt -ItemType File
Get-ChildItem -Path $bracketPath | Should -HaveCount 2
}
}
Describe 'FileSystem Provider Formatting' -Tag "CI","RequireAdminOnWindows" {
BeforeAll {