Skip to content

Fix detection of $PSHOME in front of $env:PATH - #11141

Merged
Travis Plunk (TravisEz13) merged 2 commits into
PowerShell:masterfrom
SteveL-MSFT:pshome-path
Nov 23, 2019
Merged

Travis Plunk (TravisEz13) merged 2 commits into
PowerShell:masterfrom
SteveL-MSFT:pshome-path

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Nov 21, 2019 •

Copy link
Copy Markdown
Member

PR Summary

Previous code was incorrectly detecting if $PSHOME was in front using .Contains() since a preview would have the path "$PSHOME\preview" in front. Since this affects startup, we don't want to do a bunch of string manipulation with Split() so to cover the most common case we just check if the start of $env:PATH contains $PSHOME with the path separator and if not add to front. Two scenarios that aren't covered:

  • If $PSHOME is somewhere else in $env:PATH it will be duplicated. This is unlikely and will just have a small perf impact searching $env:PATH.
  • If $env:PATH only contains $PSHOME (without the path separator), then it'll also be duplicated, but this is also unlikely with minor impact.

PR Context

PR Checklist

@TravisEz13 Travis Plunk (TravisEz13) added MustHave CL-Engine Indicates that a PR should be marked as an engine change in the Change Log labels Nov 23, 2019
@TravisEz13
Travis Plunk (TravisEz13) merged commit a1c2d3c into PowerShell:master Nov 23, 2019
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the pshome-path branch November 27, 2019 16:12
@ghost

Copy link
Copy Markdown

🎉v7.0.0-rc.1 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log MustHave

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants