-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Get-ChildItem -Recurse treats literals passed to -Path like wildcard expressions #5699
Copy link
Copy link
Closed
Closed
Copy link
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerBreaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-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.
Metadata
Metadata
Assignees
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerBreaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-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.
The 1st positional argument passed to
Get-ChildItembinds to-Path, meaning that wildcard expressions are supported.However, values that are literal paths - values that do not contain wildcard metacharacters such as
*- should be treated as such.Without
-Recurse, that is already the case: A nonexistent literal path triggers an error.With
-Recurse:Workaround (and generally the better choice if you know a path to be a literal one):
Get-ChildItem -Recurse -LiteralPath <path>Update:
Get-ChildItem -Recurse <name>may also yield false positives, by matching<name>anywhere in the subtree rather than just in the current location - see below.Steps to reproduce
Expected behavior
Both commands should report an error re nonexistent item
NoSuch.Actual behavior
Get-ChildItem NoSuch -Recurseproduces no output at all (neither success nor error), and$?is set to$True.Environment data