Skip to content

Commit 1d94e8c

Browse files
TravisEz13adityapatwardhan
authored andcommitted
Make sure we always return an object in command searcher (PowerShell#9623)
1 parent 94c1098 commit 1d94e8c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/System.Management.Automation/engine/CommandSearcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ private Collection<string> GetNextFromPathUsingWildcards(string command, out Pro
565565
}
566566

567567
provider = null;
568-
return null;
568+
return new Collection<string>();
569569
}
570570

571571
private static bool checkPath(string path, string commandName)

test/powershell/engine/Basic/CommandDiscovery.Tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,10 @@ Describe "Command Discovery tests" -Tags "CI" {
205205
}
206206
}
207207
}
208+
209+
Context "error cases" {
210+
It 'Get-Command "less `"-PsPage %db?B of %DoesNotExist:`"" should throw Drive not found' {
211+
{Get-Command -Name "less `"-PsPage %db?B of %DoesNotExist:`""} | Should -Throw -ErrorId 'DriveNotFound' -Because "The drive 'DoesNotExist:' should not exist"
212+
}
213+
}
208214
}

0 commit comments

Comments
 (0)