Skip to content

Conversation

@andyleejordan
Copy link
Member

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.

@andyleejordan andyleejordan added this to the v0.5.0 milestone Jun 8, 2016
@andyleejordan andyleejordan changed the title Andschwa/slash agnostic Make PowerShell slash-agnostic on Linux Jun 8, 2016
Copy link
Collaborator

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
}

Copy link
Member Author

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?

@vors
Copy link
Collaborator

vors commented Jun 10, 2016

Does this change include escaping to allow use "foo\bar" as a file-name on Linux as foo\bar` ?

@andyleejordan
Copy link
Member Author

@vors

This is work in progress as now I need to get escaping of backslashes to work correctly.

@vors
Copy link
Collaborator

vors commented Jun 10, 2016

LGTM, @lzybkr can you take a look?

@andyleejordan
Copy link
Member Author

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.

@andyleejordan
Copy link
Member Author

@JamesWTruher I think we need to sit-down and design how we're going to handle the escaping. There are a few options.

@andyleejordan andyleejordan force-pushed the andschwa/slash-agnostic branch 2 times, most recently from e141096 to 0232f16 Compare June 15, 2016 19:16
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.
@andyleejordan
Copy link
Member Author

@vors I added the known issue for the current behavior. Do you sign-off?

@vors
Copy link
Collaborator

vors commented Jun 15, 2016

@andschwa yes, sign off

@andyleejordan andyleejordan merged commit a3ef5c2 into master Jun 15, 2016
@andyleejordan andyleejordan deleted the andschwa/slash-agnostic branch June 15, 2016 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants