Skip to content

Powershell does not open in current directory if its name contains a left square bracket (wildcard) #5752

@adamgauthier

Description

@adamgauthier

Steps to reproduce

C:\>mkdir "[T]est"

C:\>cd "[T]est"

C:\[T]est>pwsh.exe
PowerShell v6.0.0-rc.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\Programs\PowerShell\6.0.0-rc.2>
  1. Make a directory called "[T]est".
  2. Run cmd (or powershell) and cd to the directory.
  3. Run powershell.

Expected behavior

Powershell always starts in the folder the parent process runs it in, regardless of the name of the folder.

Actual behavior

3 observed behaviors:
- Powershell starts in its home directory if the folder has left and right brackets. (ex: "Te[st]")
- Powershell starts in C:\ if the folder only has left brackets. (ex: "Te[st")
- Powershell starts in the current directory if it only has right brackets. (ex: "Te]st")

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-rc.2
PSEdition                      Core
GitCommitId                    v6.0.0-rc.2
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional Information

Hope this isn't a known issue, I've experienced it myself both when starting powershell from cmd and from Visual Studio Code ("Open in Terminal"). I've seen it discussed a little bit here. It might be related to Issue #4726. Hope we can see this fixed.

Metadata

Metadata

Assignees

Labels

Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions