Make PowerShell slash-agnostic on Linux#1081
Conversation
There was a problem hiding this comment.
just to be over the top, i expect the following tests should be done as follows:
It "Should work with backslashes for each separator" {
$testPath = "$TestDrive\testFile.txt".Replace("/","\")
Get-Content $testPath | should be $data
}
It "Should work with backslashes for each separator" {
$testPath = "$TestDrive/testFile.txt".Replace("\","/")
Get-Content $testPath | should be $data
}
It "should work even if there are too many slashes" {
$testPath = "$TestDrive//////testFile.txt"
Get-Content $testPath | should be $data
}
It "should work even if there are too many backslashes" {
$testPath = "$TestDrive\\\\\\\testFile.txt"
Get-Content $testPath | should be $data
}
There was a problem hiding this comment.
Why does a lot of slashes work?
|
Does this change include escaping to allow use "foo\bar" as a file-name on Linux as |
|
|
LGTM, @lzybkr can you take a look? |
|
This branch has more WIP, stripping out normalization and handling it explicitly for escaped backslashes. Major WIP but any pointers would welcome, it's gonna be tricky. |
|
@JamesWTruher I think we need to sit-down and design how we're going to handle the escaping. There are a few options. |
e141096 to
0232f16
Compare
Because normalization of paths occurs through the location globber and filesystem provider by way of `path.Replace(alternate, default)`, changing the alternate path separator on Linux to be '\' instead of .NET's '/' let's PowerShell be "slash agnostic."
Assuming the path may not be normalized, to make PowerShell slash
agnostic in a filesystem whose "drive" is a '/' and a 'C:\', we need to
compare to both '/' and '\' for users of PowerShell's alternate path
separator on Linux ('\').
Reverted to original code and fixed correctly.
Reverted to original code and fixed correctly.
These comparisons did not need to be changed as the input path is not modified. The normalized relate path created from the stack (if this code path is taken) is created with the correct path separators.
|
@vors I added the known issue for the current behavior. Do you sign-off? |
|
@andschwa yes, sign off |
Resolves #570.
PowerShell cmdlets now accept both '/' and '' as directory separators on Linux.
This is work in progress as now I need to get escaping of backslashes to work correctly.