-
Notifications
You must be signed in to change notification settings - Fork 8.3k
The FileSystem provider does not reliably report invalid wildcard patterns #6733
Copy link
Copy link
Closed
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerBreaking-Changebreaking change that may affect usersbreaking change that may affect usersIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-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 usersIssue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
See also: #12168
Note: This is an obscure edge case.
For the most part, malformed wildcard patterns are quietly ignored and fall back to literal treatment (e.g.,Get-Item a].txtmatches a file literally nameda].txt) - that inconsistency could be considered problematic in itself, however.Update: A pattern such as
a].txtis actually valid, because the]is not special unless preceded by[. However, patterns such asa[].txtanda[.txtanda[foo.txtare invalid, and the problem is that they are not consistently reported as such. The rest of this post has been revised accordingly.When an invalid wildcard pattern - e.g., one that ends in
[]before the filename extension - is passed toGet-ItemorGet-ChildItem, the error that should occur occurs only if at least two files exists that have the same matching prefix (the exact logic is not clear to me).(@BrucePay states that the source of the error is the FileSystem provider itself, not the cmdlets mentioned.)
Steps to reproduce
Expected behavior
That is, two instances of the same
The specified wildcard character pattern is not validerror should occur, irrespective of whether anytmp*.txtfiles exist or not.Actual behavior
That is, in the absence of any
tmp*.txtfiles, the invalid wildcard expression was not reported as invalid.Environment data
Originally reported for 6.0.2, updated for:
PowerShell Core v7.0.0