Repository navigation
Closed
Labels
Milestone
Description
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 https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/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
Activity
lzybkr commentedon Mar 24, 2017
Aren't
mvandrmthe Unix utilities? Assuming so, we shouldn't assume an argument that looks like a path is actually a Unix path.daxian-dbw commentedon Mar 24, 2017
Weird, I cannot reproduce this:
Environment
vors commentedon Mar 24, 2017
Oh yeah, I mean our versions of rm and mv (aliases)
[-]mv, rm don't work with \-paths on unix[/-][+]Move-Item, Remove-Item don't work with \-paths on unix[/+]joeyaiello commentedon Mar 24, 2017
Update the title to reflect the issue more accurately.
[-]Move-Item, Remove-Item don't work with \-paths on unix[/-][+]Move-Item, Remove-Item don't work with paths containing \, [, ] on unix[/+]vors commentedon Apr 26, 2017
The other thing with path like
[foo]is that you cannot useremove-item -recurse -force .to get rid of them.I.e.
jeffbi commentedon Apr 26, 2017
Regarding the operations on
[foo]:[foo]is a shell globbing pattern, so you should probably use-LiteralPathwhen trying to give that filename toRemove-Item.It probably still won't work right now, but I have a fix for #2799 coming that seems to also fix that, as well as the
Remove-Item -Recurse -Force *issue. I haven't looked at this for the\character, so I can't yet say whether my changes will fix that part.vors commentedon Apr 26, 2017
jeffbi oh, awesome to see that you working on it!
give the same result. I tried few things like explicit escaping with backticks and nothing seems to work.
9 remaining items
anmenaga commentedon Aug 28, 2017
Verified on latest release (v6.0.0-beta.6) on Ubuntu14 that
Move-Item,Remove-Itemwork as expected with[,],*when-LiteralPathparameter is used.anmenaga commentedon Aug 28, 2017
The remaining thing for this issue are backslashes (
\) that are covered in greater detail in a linked issue #3666 (On Unix, PowerShell will not find files with backslashes in their names), so closing this one.