Skip to content

Move-Item, Remove-Item don't work with paths containing \, [, ] on unix #3414

@vors

Description

@vors

Steps to reproduce

On macOS or Linux touch '1\2'
Try mv 1\2 2, try rm 1\2

The real-world example of when you are getting \ without knowing it is PowerShell/Microsoft.PowerShell.Archive#11

The problem happens not only with Compress-Archive, but with other archive programs too. So macOS users need a way to bulk-rename files with \ in the name and PS doesn't provide a way to do it at the moment.

UPD: same problem for paths like [foo].

Expected behavior

PowerShell should be able to perform the operations

Actual behavior

Paths are getting normalized to 1/2

rm : Cannot find path '/Users/vors/dev/PowerShell/1/2' because it does not exist.

Environment data

> $PSVersionTable

Name                           Value                                                                                
----                           -----                                                                                
PSVersion                      6.0.0-alpha                                                                          
PSEdition                      Core                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                              
BuildVersion                   3.0.0.0                                                                              
GitCommitId                    v6.0.0-alpha.17                                                                      
CLRVersion                                                                                                          
WSManStackVersion              3.0                                                                                  
PSRemotingProtocolVersion      2.3                                                                                  
SerializationVersion           1.1.0.1                                                                              

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions