Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Set-Location without any parameters changes location to %UserProfile% directory #6791

Closed
st0le opened this issue May 1, 2018 · 6 comments
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-By Design The reported behavior is by design.

Comments

@st0le
Copy link
Contributor

st0le commented May 1, 2018

Steps to reproduce

Call Set-Location or cd

PS C:\Users\gakama\Desktop> set-location D:\
PS D:\> cd
PS C:\Users\gakama> set-location D:\
PS D:\> Set-Location
PS C:\Users\gakama>

Expected behavior

Without any parameters, it shouldn't change the current location.

Here's the output from Powershell 5.1

PS C:\Users\gakama\Desktop> Set-Location d:
PS D:\> cd
PS D:\>

Actual behavior

The location changes to "%USERPROFILE%" (C:\Users\<username>)

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.2
PSEdition                      Core
GitCommitId                    v6.1.0-preview.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
@SteveL-MSFT SteveL-MSFT added the Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif label May 2, 2018
@SteveL-MSFT
Copy link
Member

This was an explicit design decision (and yes, a breaking change from Windows PowerShell) mimicking Bash

@st0le
Copy link
Contributor Author

st0le commented May 2, 2018

Coming from Windows it caught me by surprise.

@st0le st0le closed this as completed May 2, 2018
@iSazonov iSazonov added the Resolution-Answered The question is answered. label May 26, 2018
@iSazonov
Copy link
Collaborator

Is this change documented?

@SteveL-MSFT
Copy link
Member

@iSazonov created MicrosoftDocs/PowerShell-Docs#2480

@iSazonov
Copy link
Collaborator

@SteveL-MSFT It's really amazing behavior on Windows because Windows users expect in contrast to Unix that default working directory is Documents not profile root folder.

/cc @mklement0 What do you think?

@iSazonov iSazonov added Resolution-By Design The reported behavior is by design. and removed Resolution-Answered The question is answered. labels May 31, 2018
@mklement0
Copy link
Contributor

@iSazonov:

The behavior is consistent: the equivalent locations - $HOME - are targeted on all platforms.

It is a fact of Windows life that creating files and folders directly in $HOME is ill-advised - albeit possible. Yes, using Documents for user-created content is the right choice, but it is only a convention.

This asymmetry in how the $HOME folder is used between Unix-like platforms and Windows is unfortunate, but in this case I think it's more important to be consistent and stick with the well-defined, directly equivalent $HOME on all platforms.

That said, it would generally be handy for Set-Location to support the special / well-known folders supported by [Environment]:: via the [Environment+SpecialFolder] enumeration, so that you could do something like:

Set-Location -SpecialFolder MyDocuments 

See #6966

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-By Design The reported behavior is by design.
Projects
None yet
Development

No branches or pull requests

4 participants