-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Make PowerShell slash-agnostic on Linux #1081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.