-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
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 productOS-LinuxOS-macOSResolution-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.
Description
Note:
- Applies to Linux and macOS, but not to Windows
- Possibly related: Get-ChildItem: wildcard matching behavior differs between -Path and -Include parameters when using escape characters #3724
Wildcard patterns- at least in the context of Get-Item - support ` as the escape character to represent literal ` instances in a path and to escape the following metacharacters: * ? [ ]
Remove-Item and Move-Item currently do not support that, neither with -Path nor with -Include.
Steps to reproduce
# Create a file that contains a literal backtick and a literal substring that would be a valid
# sub-pattern if interpreted as a wildcard expression.
New-Item -Type File 'a`[b]'
# Match the newly created file using a wildcard expression with suitable escaping.
Remove-Item * -Include 'a```[b`]' -WhatIf
Remove-Item -Path 'a```[b`]' -WhatIf
Move-Item * -Include 'a```[b`]' /tmp -WhatIf
Move-Item -Path 'a```[b`]' /tmp -WhatIfExpected behavior
Both commands in each pair should find the target file and output information about how it would be deleted / moved.
Actual behavior
All commands unexpectedly fail to find the file:
Remove-Item : An object at the specified path /Users/jdoe/a`[b] does not exist.
...
Curiously, the error message quotes the correct literal path that it claims doesn't exist.
Move-Item's symptoms differ:
Move-Item : Cannot move item because the item at '...' does not exist.
...
Move-Item : The specified wildcard character pattern is not valid: a\[b
Curiously, all existing files in the directory (even those that don't match the pattern) are reported as non-existent.
Environment data
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on macOS 10.12.4
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Ubuntu 16.04Metadata
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 productOS-LinuxOS-macOSResolution-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.