Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Passing a provider-name-prefixed path to Set-Location makes $PWD retain the prefix #10522

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Perhaps related: #9293

Steps to reproduce

Run the following on Windows (works analogously on Unix):

Set-Location Microsoft.PowerShell.Core\FileSystem::C:\Windows
"$PWD" | Should -Be C:\Windows

Note: A real-life scenario in which this could occur is if you pipe the output from a New-Item -Type Directory call to Set-Location, e.g.:

New-Item -Type Directory $HOME -Force | Set-Location

Expected behavior

The test should pass.

Actual behavior

The test fails:

Expected strings to be the same, but they were different.
Expected length: 10
Actual length:   48
Strings differ at index 0.
Expected: 'C:\Windows'
But was:  'Microsoft....'

That is, $PWD stringified (via .Path) to 'Microsoft.PowerShell.Core\FileSystem::C:\Windows', not the expected C:\Windows, as also reflected in the prompt string afterwards (via $executionContext.SessionState.Path.CurrentLocation).

While $PWD.ProviderPath does reflect the unprefixed (but always native) fileysystem path, relying on "$PWD" or $PWD.Path to do that too is very common.

Environment data

PowerShell Core 7.0.0-preview.3
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.The issue won't be fixed, possibly due to compatibility reason.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.