Join-Path doesn't handle provider prefixes correctly on Unix-like platforms
See original GitHub issueSteps to reproduce
On macOS or Linux:
Join-Path (Get-Item .).PSParentPath foo | Should -Be "$((Get-Item .).PSParentPath)/foo"
Expected behavior
The test should succeed.
Actual behavior
The test fails, because the existing provider prefix isn’t recognized as such, causing its \
separator to be normalized to /
and another provider prefix to be prepended.
Expected strings to be the same, but they were different. Expected length: 65 Actual length: 103 Strings differ at index 38. Expected: '...tem::/User...' But was: '...tem::Micro...'
That is, Join-Path
’s output was something like (note the doubled provider prefix, with the 2nd one using /
):
Microsoft.PowerShell.Core\FileSystem::Microsoft.PowerShell.Core/FileSystem::/Users/jdoe/Desktop/foo
Environment data
PowerShell Core 7.2.0-preview.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Why doesn't os.path.join() work in this case?
join () is to make your program cross-platform (linux/windows/etc). Even one slash ruins it. So it only makes sense when being used with...
Read more >Path.Combine() isn't as cross-platform as you think it is
I started using .NET pretty close to the beginning, in either 2002 or 2003. It's hard to accurately remember things that happened before...
Read more >prevent PowerShell autocomplete from adding dot prefix
As far as I'm concerned, I'd like it to be turned off everywhere—I can remember to type .\foo.exe instead of foo.exe for the...
Read more >Join-Path - PowerShell
This command uses Join-Path to combine a path with a childpath. Since the command is executed from the FileSystem provider, it provides the...
Read more >Joining Linux Hosts to an Active Directory Domain with ...
Read this guide to learn how to integrate Linux with Active Directory. We'll also cover how to join AD using realmd, what using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@octos4murai I haven’t seen anyone else wanting to take it up, and it seems a fairly clear case of the behaviour being bugged, so yeah, we may as well consider it up for grabs. 🙂
@iSazonov, yes, because the problem is related to normalizing
\
to/
.