-
Notifications
You must be signed in to change notification settings - Fork 8.3k
On Unix, PowerShell will not find files with backslashes in their names #3666
Copy link
Copy link
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 productResolution-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 providerIssue-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-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.
This is similar to #3414, but involves only the backslash portion.
The basis of the problem is premature normalization of paths. Path normalization happens quite early (and very frequently and in a great number of places in the PowerShell code) while processing a command. Usually this happens before the path reaches its provider, and often that normalization is a brute-force change one slash to another mechanism. Thus a path such as
1\2on Unix is "normalized" to1/2, ensuring that the path will never be found.Using
-LiteralPathdoes not prevent the path normalization, so that is not a workaround.Steps to reproduce
From bash:
$ touch 'a\b'then from PowerShell:
or
Expected behavior
The file
a\bis deletedActual behavior
Environment data