-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Get-ChildItem -path '/' breaks -exclude or -include parameters #15497
Copy link
Copy link
Open
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productNeeds-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management moduleWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Description
I believe there is a bug with Get-ChildItem for pwsh v7.1.3 on Ubuntu 20.04 (WSL2) when using the -exclude and -include parameters in conjunction with the -Path '/' parameter/argument combo.
This seems primarily be limited to Get-ChildItem -Path '/' as both -LiteralPath '/' and -PSPath (Get-Item -Path '/').PSPath return the data as expected when used with either -exclude or -include.
Additionally using -exclude and -path together works for directories outside /. However, I believe there may be another bug when using -Path and -Include other places as well.
Steps to reproduce
Get-ChildItem -Path '/' -Exclude 'mnt'
# Bad:
Get-ChildItem -Path '/' -Exclude 'mnt'
# Aligns with expected behavior:
Get-ChildItem -Path '/mnt' -Exclude 'c'
Get-ChildItem -LiteralPath '/' -Exclude 'mnt'
Get-ChildItem -PSPath (Get-Item -Path '/').PSPath -Exclude 'mnt'Get-ChildItem -Path '/' -Include 'mnt'
# Bad:
Get-ChildItem -Path '/' -Include 'mnt' # Produces error
Get-ChildItem -Path '/mnt' -Include 'c' # Produces no output when output is expected.
# Aligns with expected behavior:
Get-ChildItem -LiteralPath '/' -Include 'mnt'
Get-ChildItem -LiteralPath '/mnt' -Include 'c'
Get-ChildItem -PSPath (Get-Item -Path '/').PSPath -Include 'mnt'
Get-ChildItem -PSPath (Get-Item -Path '/mnt').PSPath -Include 'c'I'm unsure if the behavior of -Include deserves its own bug report but would be happy to split it up if needed.
Environment data
StackTrace:
at Microsoft.PowerShell.Commands.FileSystemProvider.GetChildName(String path) in /PowerShell/src/System.Management.Automation/namespaces/FileSystemProvider.cs:line 5683
at System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName(String path, CmdletProviderContext context) in /PowerShell/src/System.Management.Automation/namespaces/NavigationProviderBase.cs:line 174
at System.Management.Automation.LocationGlobber.ExpandMshGlobPath(String path, Boolean allowNonexistingPaths, PSDriveInfo drive, ContainerCmdletProvider provider, CmdletProviderContext context) in /PowerShell/src/System.Management.Automation/namespaces/LocationGlobber.cs:line 2763
at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext context, Boolean allowNonexistingPaths, CmdletProvider& providerInstance) in /PowerShell/src/System.Management.Automation/namespaces/LocationGlobber.cs:line 516
at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, CmdletProvider& providerInstance) in /PowerShell/src/System.Management.Automation/namespaces/LocationGlobber.cs:line 218
at System.Management.Automation.LocationGlobber.GetGlobbedProviderPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, ProviderInfo& provider, CmdletProvider& providerInstance) in /PowerShell/src/System.Management.Automation/namespaces/LocationGlobber.cs:line 779
at System.Management.Automation.SessionStateInternal.GetChildItems(String path, Boolean recurse, UInt32 depth, CmdletProviderContext context) in /PowerShell/src/System.Management.Automation/engine/SessionStateContainer.cs:line 1393
at System.Management.Automation.ChildItemCmdletProviderIntrinsics.Get(String path, Boolean recurse, UInt32 depth, CmdletProviderContext context) in /PowerShell/src/System.Management.Automation/engine/ChildrenCmdletProviderInterfaces.cs:line 278
at Microsoft.PowerShell.Commands.GetChildItemCommand.ProcessRecord() in /PowerShell/src/Microsoft.PowerShell.Commands.Management/commands/management/GetChildrenCommand.cs:line 318
at System.Management.Automation.Cmdlet.DoProcessRecord() in /PowerShell/src/System.Management.Automation/engine/cmdlet.cs:line 173
at System.Management.Automation.CommandProcessor.ProcessRecord() in /PowerShell/src/System.Management.Automation/engine/CommandProcessor.cs:line 388
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productNeeds-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management moduleWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.


