Powershell: Set-Location -LiteralPath does not treat "-" and "+" as literals.

Created on 19 Oct 2018  路  7Comments  路  Source: PowerShell/PowerShell

From great feature, I would say Navigation is impossible to folder named - and +

image

Set-Location -LiteralPath - as well

Environment data


Name                           Value
----                           -----
PSVersion                      6.2.0-preview.1
PSEdition                      Core
GitCommitId                    6.2.0-preview.1
OS                             Microsoft Windows 10.0.18262 
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Bug Resolution-Fixed

Most helpful comment

Set-Location -LiteralPath - should treat it as a literal path and not Pop-Location so that is a bug. We can use this issue to track that.

All 7 comments

Surely this is accessible with cd .\- and cd .\+?

@vexx32 But that's not how directory navigation should be.

That's an opinion, not a fact. And I'm sure folks accustomed to using cd - and cd + on Linux would disagree there. 馃槃

Cc @SteveL-MSFT , I thought of asking this at your session yesterday @PSConfAsia, but my lappie was not with me...

You have a similar issue with a dir named [foo]. You can cd to it with cd -lp [foo] but the same doesn't work with cd -lp -. I think perhaps that should work in addition to cd .\-.

Yeah, I'd agree that -LiteralPath should not exhibit the history-navigation behaviour for obvious reasons!

Set-Location -LiteralPath - should treat it as a literal path and not Pop-Location so that is a bug. We can use this issue to track that.

Was this page helpful?
0 / 5 - 0 ratings