You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[System.Management.Automation.ProviderInfo] (returned by Get-PSProvider) should contain path-separator information #5544
Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Currently, there is no way to learn of the path-separator character(s) that must be used to separate the components of a path for a given provider, because [System.Management.Automation.ProviderInfo], as returned by Get-PSProvider, has no such property.
In the absence of such information, users may be tempted to assume that \ and / can be universally - and interchangeably - used, which is not necessarily true; for instance, the registry provider only properly supports \, given that / is a valid char. in registry key names - see #5536
Future providers - or even existing third-party providers - could conceivably use completely different characters (of necessity).
Adding a [string[]]-typed .PathSeparator property to [System.Management.Automation.ProviderInfo] would help.
Additional considerations:
Non-hierarchical providers such as the Variable and Function providers have no real need for a path separator: e.g., Get-Item variable:PSHome works just fine. In practice, these providers follow the FileSystem provider's example and allow interchangeable use of / and \, and tab completion even explicitly inserts these optional chars.: / on Unix, and \ on Windows.
Third-party implementers of providers will need to provide appropriate values for .PathSeparator too.
The name to give this new property is debatable, given that the .NET framework has already sown confusion around [System.IO.Path]::DirectorySeparator (the path-component separator) vs. [System.IO.Path]::PathSeparator (the path-environment-variable-entry separator). However, given that the term directory is filesystem-specific and we're talking about abstractions here, my vote is still for .PathSeparator.
So far, I have already added a PathSeparator property on the ProviderInfo class.
Now I am going through the code to figure out where do I have to set the values for PathSeparator in each of the Provider. For what I have read in the code the best location to update the property would be in the Start method of each the provider.
I would recommend doing what you can to get it to a point where it works, add some tests in, and then open a PR. If the PS Team want to direct you to better or more apropos places to put specific details in, they'll be happy to do it there, where they can see the changes you've made. 🙂
given that the term directory is filesystem-specific and we're talking about abstractions here, my vote is still for .PathSeparator.
My first look was on FileSystem provider and the name confused me. It will always confuse users in the context. So I think we need another abstraction name.
We use New-Item for all providers and Item corresponds "item of path" in FileSystem provider. I'd expect that .Net Core [System.IO.Path]::PathSeparator transforms to ItemSeparator.
On the other hand, we have Join-Path. If we had a PathSeparator parameter there, what would it mean? Again confuse.
Ilya (@iSazonov): I'm not sure I understand all your points, but let me try to respond:
It will always confuse users in the context. So I think we need another abstraction name.
Why? To me, the confusion stems only from [System.IO.Path]::PathSeparator, but I don't think we should worry about that - it's .NET's confusion, not PowerShell's.
Strictly speaking, we're looking for the character that is used to separate item names that are sequenced to form a path - PathSeparator seems like the most intuitive choice to me.
I guess ItemSeparator would work too, but to me it's preferable to mention the relevant concept in the name: a path [of item names].
I'd expect that .Net Core [System.IO.Path]::PathSeparator transforms to ItemSeparator.
[System.IO.Path]::PathSeparator has no relationship to providers per se, and shouldn't be reflected there - it's a character used by convention to separate paths as a whole in a reserved environment variable (and, as an aside, is itself a legal filename character on its respective platforms). Whether and where to represent this other separator in PowerShell too is a separate question; my name suggestion would be PathVariableSeparator.
On the other hand, we have Join-Path. If we had a PathSeparator parameter there, what would it mean? Again confuse.
In line with the new property, it would refer to the separator used to separate item names in a path - where is the confusion?
Agreed with using PathVariableSeparator or even something a degree more removed perhaps, like PathVariableDelimiter because its function is so completely different to PathSeparator; it's not separating portions of a path, it's usually a character that can't be used in a path at all, so it serves to clearly delimit individual values in the environment variable.
Thanks, Rain Sallow (/u/ta11ow) (@vexx32), but I suggest sticking with "separator" as the most familiar term (for which "delimiter" is a near-synonym with no clear distinction), because in the abstract the functionality is the same:
A list or sequence (path) is formed from entries, and a character is placed between those entries to mark their boundaries.
The entries just happen to be different entities:
In the case of $env:PATH, the entities happen to be filesystem paths themselves (and, as stated, strictly speaking you can use : in filesystem paths on Unix, and ; on Windows, but it's probably a bad idea).
In the case of a provider path, the entities happen to be item names (file/directory names, in the case of the filesystem provider)
Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Activity
renehernandez commentedon Jan 2, 2019
Michael Klement (@mklement0) I am working on this issue,
So far, I have already added a
PathSeparatorproperty on theProviderInfoclass.Now I am going through the code to figure out where do I have to set the values for
PathSeparatorin each of the Provider. For what I have read in the code the best location to update the property would be in theStartmethod of each the provider.Any suggestions?
vexx32 commentedon Jan 3, 2019
That seems like a good start to me Rene Hernandez (@renehernandez). 😄
I would recommend doing what you can to get it to a point where it works, add some tests in, and then open a PR. If the PS Team want to direct you to better or more apropos places to put specific details in, they'll be happy to do it there, where they can see the changes you've made. 🙂
iSazonov commentedon Jan 6, 2019
My first look was on FileSystem provider and the name confused me. It will always confuse users in the context. So I think we need another abstraction name.
We use
New-Itemfor all providers andItemcorresponds "item of path" in FileSystem provider. I'd expect that .Net Core [System.IO.Path]::PathSeparator transforms to ItemSeparator.On the other hand, we have Join-Path. If we had a PathSeparator parameter there, what would it mean? Again confuse.
mklement0 commentedon Jan 7, 2019
Ilya (@iSazonov): I'm not sure I understand all your points, but let me try to respond:
Why? To me, the confusion stems only from
[System.IO.Path]::PathSeparator, but I don't think we should worry about that - it's .NET's confusion, not PowerShell's.Strictly speaking, we're looking for the character that is used to separate item names that are sequenced to form a path -
PathSeparatorseems like the most intuitive choice to me.I guess
ItemSeparatorwould work too, but to me it's preferable to mention the relevant concept in the name: a path [of item names].[System.IO.Path]::PathSeparatorhas no relationship to providers per se, and shouldn't be reflected there - it's a character used by convention to separate paths as a whole in a reserved environment variable (and, as an aside, is itself a legal filename character on its respective platforms). Whether and where to represent this other separator in PowerShell too is a separate question; my name suggestion would bePathVariableSeparator.In line with the new property, it would refer to the separator used to separate item names in a path - where is the confusion?
vexx32 commentedon Jan 7, 2019
Agreed with using
PathVariableSeparatoror even something a degree more removed perhaps, likePathVariableDelimiterbecause its function is so completely different to PathSeparator; it's not separating portions of a path, it's usually a character that can't be used in a path at all, so it serves to clearly delimit individual values in the environment variable.mklement0 commentedon Jan 7, 2019
Thanks, Rain Sallow (/u/ta11ow) (@vexx32), but I suggest sticking with "separator" as the most familiar term (for which "delimiter" is a near-synonym with no clear distinction), because in the abstract the functionality is the same:
A list or sequence (path) is formed from entries, and a character is placed between those entries to mark their boundaries.
The entries just happen to be different entities:
$env:PATH, the entities happen to be filesystem paths themselves (and, as stated, strictly speaking you can use:in filesystem paths on Unix, and;on Windows, but it's probably a bad idea).