Skip to content

Enable backslash as alternative path delimiter #570

@vors

Description

@vors

Windows PowerShell allows both \ and / be path delimiters.

Consider

#  Full PS on Windows
PS C:\> 'foo' > bar
PS C:\> cat ./bar
foo
PS C:\> cat .\bar
foo

Versus

# Linux version
PSL /Users/vors/dev/PowerShell-Linux> 'foo' > bar
PSL /Users/vors/dev/PowerShell-Linux> cat ./bar
foo
PSL /Users/vors/dev/PowerShell-Linux> cat .\bar
cat : Cannot find path '/Users/vors/dev/PowerShell-Linux/.\bar' because it does not exist.

It's a problem for porting: there are scripts that could run as-is, but don't because of the wrong path delimiters.

On the other hand, on Linux you can create a folder foo\bar, so adding \ as alternative path separator would make this corner case harder.

This problem can be solved with additional escaping

cd foo`\bar

Sidenote: 'Set-Location' (cd) currently fails for it, but Get-ChildItem (ls) works

PSL /Users/vors/dev/PowerShell-Linux> ls ./foo\bar/


    Directory: /Users/vors/dev/PowerShell-Linux/foo\bar


Mode                LastWriteTime         Length Name                                                                                                                    
----                -------------         ------ ----                                                                                                                    
------          2/20/16   9:38 PM              6 1   


PSL /Users/vors/dev/PowerShell-Linux> cd ./foo\bar/
cd : An object at the specified path /Users/vors/dev/PowerShell-Linux/foo\bar does not exist.

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productUsability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions