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
Namespace variable notation referencing the FileSystem provider is broken on Unix platforms #3245
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
changed the title [-]Namespace variable notation is broken on Unix platforms[/-][+]Namespace variable notation referencing the FileSystem provider is broken on Unix platforms[/+]on Mar 3, 2017
Namespace notation does work but not when using "/:" as the drive. If you create a new drive named 'root' New-PSDrive -PSProvider filesystem -root / -scope global -name root:
Then cd into that drive cd "root:$home"
doing ${root:foo.txt} = 'hi, mom' Get-Content foo.txt
works fine.
In fact you can't use '/:' as a drive anywhere. For example, resolve-path /: fails with path not found whereas resolve-path root: works fine. This appears to be the real issue - that you can't use '/' as a drive name in paths.
PS /home/steve>New-PSDrive-Root /-PSProvider FileSystem -Name /:
New-PSDrive : Cannot process the drive name because the drive name contains one
or more of the following characters that are not valid: ; ~ / \ . :
At line:1 char:1+New-PSDrive-Root /-PSProvider FileSystem -Name /:
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-PSDrive], PSArgumentExcep
tion
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.NewPSDriveCo
mmand
Should we support this? Perhaps the solution is to simply have root: defined as / on Linux systems.
Still doesn't work as of 6.2. Is the '/' drive merely a requirement internal to powershell so that it lists the filesystem provider in the drives list? While I understand that this would be a weird concept to Linux people to use something like dir /:., the fact it is listed (by get-psdrive) would make me think it should at least work, even though its not needed in that example.
Same on 7.3.4. This seems to be related to the differences with cd / on Windows and non-Windows platforms. cd alias: cd / leaves one at alias: on Windows, but the rootfs on non-Windows.
Following this pattern on non-Windows, I propose a simpler syntax. How about we make ${/a/b/c} on non-Windows like ${c:\a\b\c} on Windows, and on Windows keep the old behavior of resolving to ${variable:/a/b/c}. This will only change strange scripts that name variables with leading slashes and make PowerShell more consistent across platforms.
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Activity
[-]Namespace variable notation is broken on Unix platforms[/-][+]Namespace variable notation referencing the FileSystem provider is broken on Unix platforms[/+]BrucePay commentedon Mar 4, 2017
Namespace notation does work but not when using "/:" as the drive. If you create a new drive named 'root'
New-PSDrive -PSProvider filesystem -root / -scope global -name root:Then cd into that drive
cd "root:$home"doing
${root:foo.txt} = 'hi, mom'Get-Content foo.txtworks fine.
In fact you can't use '/:' as a drive anywhere. For example,
resolve-path /:fails with path not found whereasresolve-path root:works fine. This appears to be the real issue - that you can't use '/' as a drive name in paths.SteveL-MSFT commentedon Mar 5, 2017
The FileSystem provider explicitly disallows it:
Should we support this? Perhaps the solution is to simply have root: defined as / on Linux systems.
iSazonov commentedon Oct 8, 2017
Michael Klement (@mklement0) We had related PRs - could you please re-check the Issue?
mklement0 commentedon Sep 16, 2018
Ilya (@iSazonov): Sorry, I just realized that I never responded:
It is still broken as of v6.1.0
msftrncs commentedon Mar 30, 2019
Still doesn't work as of 6.2. Is the '/' drive merely a requirement internal to powershell so that it lists the filesystem provider in the drives list? While I understand that this would be a weird concept to Linux people to use something like
dir /:., the fact it is listed (byget-psdrive) would make me think it should at least work, even though its not needed in that example.danielzgtg commentedon Jun 22, 2023
Same on 7.3.4. This seems to be related to the differences with
cd /on Windows and non-Windows platforms.cd alias: cd /leaves one atalias:on Windows, but the rootfs on non-Windows.Following this pattern on non-Windows, I propose a simpler syntax. How about we make
${/a/b/c}on non-Windows like${c:\a\b\c}on Windows, and on Windows keep the old behavior of resolving to${variable:/a/b/c}. This will only change strange scripts that name variables with leading slashes and make PowerShell more consistent across platforms.microsoft-github-policy-service commentedon Dec 20, 2023
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.