Skip to content

Set-Location -Path + fails because it mishandles the history #14279

@skycommand

Description

@skycommand

Steps to reproduce

Open a PowerShell 7.1 window, navigate to a safe folder for experimentation, and issue the following commands:

# Create a folder called '[Meta]'. Careful! '-Type Folder' doesn't work!
New-Item -Name '[Meta]' -Type Directory

# Output:
# 
#    Directory: C:\Users\FrankAbignaleXIII\Desktop
#
# Mode                 LastWriteTime         Length Name
# ----                 -------------         ------ ----
# d----          2020-11-27    23:37                [Meta]
#

# Change the current folder to '[Meta]'
Set-Location -Path '.\`[Meta`]\'

# Navigate back to "Desktop"
Set-Location -Path '-'

# Navigate forward to '[Meta]'
Set-Location -Path '+'

Expected behavior

After following the reproduction steps, the user expects the current folder to be the '[Meta]' folder.

Actual behavior

In PowerShell 7.1, I received the following error:

Set-Location: Cannot find path 'C:\Users\FrankAbignaleXIII\Desktop\[Meta]' because it does not exist.

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.0
PSEdition                      Core
GitCommitId                    7.1.0
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileSystem-Providerspecific to the FileSystem providerIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions