Skip to content

Fix System32 module path duplication#7414

Merged
daxian-dbw merged 6 commits intoPowerShell:masterfrom
rjmholt:fix-powershell-path-duplication
Aug 3, 2018
Merged

Fix System32 module path duplication#7414
daxian-dbw merged 6 commits intoPowerShell:masterfrom
rjmholt:fix-powershell-path-duplication

Conversation

@rjmholt
Copy link
Copy Markdown
Collaborator

@rjmholt rjmholt commented Jul 31, 2018

PR Summary

Resolves #7327. PowerShell Core subprocesses will only append the System32 module path to the PSModulePath when it is not already present.

PR Checklist

@rjmholt rjmholt requested a review from BrucePay as a code owner July 31, 2018 18:31
Copy link
Copy Markdown
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

With one minor comment

pwsh.exe -C '$null = $env:PSModulePath -match ([regex]::Escape((Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"))); $matches.Count'
}

$sys32ModPathCount -le 1 | Should -BeTrue
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should it always be 1?
We could use Should -BeLessOrEqual.

Copy link
Copy Markdown
Collaborator Author

@rjmholt rjmholt Aug 1, 2018

Choose a reason for hiding this comment

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

Good thought! Will fix

@anmenaga
Copy link
Copy Markdown

anmenaga commented Aug 1, 2018

Restarted travis-ci test run.

Copy link
Copy Markdown

@anmenaga anmenaga left a comment

Choose a reason for hiding this comment

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

LGTM

Restore-ModulePath
}

It "Allows Windows PowerShell subprocesses to call `$PSHome modules still" -Skip:(-not $IsWindows) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-Skip:(-not $IsWindows) shouldn't be needed here as you have $PSDefaultParameterValues set at the beginning.

It "Allows Windows PowerShell subprocesses to call `$PSHome modules still" -Skip:(-not $IsWindows) {
$errors = powershell.exe -Command "Get-ChildItem" 2>&1 | Where-Object { $_ -is [System.Management.Automation.ErrorRecord] }
$errors | Should -Be $null
It "Allows PowerShell Core 6 subprocesses to call core modules" -Skip:(-not $IsWindows) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here.

@daxian-dbw daxian-dbw merged commit dbdcf6e into PowerShell:master Aug 3, 2018
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.

System32 module path is added repeatedly in subprocesses

4 participants