Powershell: cd-ing to a new drive and back does not restore path

Created on 27 Apr 2018  路  6Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

C:\Users\me\Documents> cd Z:
Z:\> cd C:

Expected behavior

Z:\> cd C:
C:\Users\me\Documents>

Actual behavior

Z:\> cd C:
C:\>

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.1
PSEdition                      Core
GitCommitId                    v6.1.0-preview.1-99-g35d8de927b8e408461a5b4fc40ba20016c68433e
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

It looks like https://github.com/PowerShell/PowerShell/pull/6600 caused a regression. It seems to be Windows only. I tested with https://github.com/PowerShell/PowerShell/commit/a9781dedc29978fd4b41d02d1a59826461d14b4c with no repro and then with https://github.com/PowerShell/PowerShell/commit/35d8de927b8e408461a5b4fc40ba20016c68433e to successfully repro.

Credit to @jianyunt.

Issue-Bug Resolution-Fixed WG-Engine-Providers

Most helpful comment

Hoping to have some time this weekend to take a closer look at this regression. Thanks for filing the issue!

All 6 comments

We need add new tests for this but I guess CI has only one filesystem drive.

@iSazonov We could use New-PSDrive -Name TestSetLocation -Provider FileSystem -Root Path\To\Root and later Remove-PSDrive -Name TestSetLocation later. Alternatively, we could use subst.exe for Windows.

@GeeLaw Thanks! I guess we could use New-PSDrive -Name "Z" -Provider FileSystem -Root Path\To\Root - seems one char name can be important in the test.

Hoping to have some time this weekend to take a closer look at this regression. Thanks for filing the issue!

Dug into this tonight and I think this may be a move in the right direction. The expected behavior as noted by @rjmholt is produced.

@mcbobke Feel free push PR - now we know what tests we need to add to exclude a regression.

Was this page helpful?
0 / 5 - 0 ratings