Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Jun 25, 2018

PR Summary

This was an issue introduced by 7459b54.

When in a PSDrive, and you set-location to a root qualified path, it should be based on the current psdrive and not the filesystem. Exception is on non-Windows, all paths start with / so it's always treated as filesystem.

PR Checklist

@iSazonov
Copy link
Collaborator

Exception is on non-Windows, all paths start with / so it's always treated as filesystem.

Now I try dir / on SCCM provider, it returns 18 values. If the provider will be ported users can do dir /application on non-Windows.

@SteveL-MSFT
Copy link
Member Author

@iSazonov There's a fundamental problem with PSDrives on non-Windows and will probably become a bigger issues as more SHiPS based providers are written that are cross platform. We should discuss that here #6773

Copy link
Collaborator

@BrucePay BrucePay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

It "Should not use filesystem root folder if not in filesystem provider" -Skip:(!$IsWindows) {
# find filesystem root folder that doesn't exist in HKCU:
$foundFolder = $false
foreach ($folder in (Get-ChildItem "${env:SystemDrive}\" -Directory)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parens around Get-ChildItem are unnecessary.

# find filesystem root folder that doesn't exist in HKCU:
$foundFolder = $false
foreach ($folder in (Get-ChildItem "${env:SystemDrive}\" -Directory)) {
if (!(Test-Path "HKCU:\$($folder.Name)")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the convention is to use -not instead of ! simply because it's more visible.

}
}
$foundFolder | Should -BeTrue
Set-Location HKCU:\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Push-Location HKCU:\ in try and Pop-Location in finally to reset the current working directory.

Copy link
Member Author

@SteveL-MSFT SteveL-MSFT Jun 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for Set-Location tests, though. There's a BeforeAll and AfterAll that sets the location back to where it was.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. closed.

@anmenaga
Copy link

anmenaga commented Jul 2, 2018

@adityapatwardhan this needs your review approval. It looks ready for merge.

@SteveL-MSFT
Copy link
Member Author

@adityapatwardhan can you re-review?

@adityapatwardhan adityapatwardhan merged commit e5e1c53 into PowerShell:master Jul 11, 2018
@SteveL-MSFT SteveL-MSFT deleted the set-location-test branch October 26, 2018 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants