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

Backport PR #9250 into PowerShell 6.x #10940

Copy link
Copy link
@glennsarti

Description

@glennsarti
Issue body actions

Currently when using Set-Location (or it's cd alias) the FileSystem provider will use the literal text that is entered. For example:

Given a filesystem with following layout:

C:\
  |
  + Users
  + Windows

Issuing the following PowerShell commands results in:

PS C:\> cd Users
PS C:\Users> cd ..
PS C:\> cd users
PS C:\users>

Note - The last command used the path users instead of the actual name Users

This contrary to:

  • Using tab completion
    Tab completion resolves to the name on disk

  • "magic" paths like tilde (~)

PS C:\> cd ~
PS C:\Users\glenn.sarti>
  • 8.3 Alternate names
PS C:\> cd C:\progra~1
PS C:\Program Files>

This can cause issues with child process creation, as the working directory passed to the child process, strictly speaking, does not exist. This is proved simply by calling cmd.exe:

Given the filesystem layout example above (C:\Users is the correct name, not C:\users)

C:\users> cmd.exe /c cd
C:\users

Note that cmd.exe outputs the "invalid" directory of C:\users

Note that, while strictly the fault of PowerShell, I have seen other cross-platform tools behave in strange ways (for example Ruby and NodeJS) where they are performing file path operations and raise errors because the current working directory is not what is on disk.


This appears to be "fixed" in PowerShell 7.x via #9250. This issue is to backport these fixes into PowerShell 6.x

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-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-AnsweredThe question is answered.The question is answered.

    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.