GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — AddToPath re-implementation in install-powershell.ps1 by glachancecmaisonneuve · Pull Request #8081 · PowerShell/PowerShell Conversation
Contributor
PR SummaryThis PR is a re-implementation of the -AddToPath switch in tools/install-powershell.ps1, without the side-effects the current implementation has. The changes only affects windows users. Summarized changesAs currently implemented, the -AddToPath switch has quite a few undesirable side-effects and 1 or 2 issues that prevents it from adding the path to the newly installed powershell to the registry. Specifically:
This PR remedies all of the above by
Non-Breaking change
An alternate fix (dont do anything for -AddToPath when $WinEnv -eq $true)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
PRASOON KARUNAN V (kvprasoon)
approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Travis Plunk (TravisEz13)
requested changes
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Co-Authored-By: glachancecmaisonneuve <[email protected]> Co-Authored-By: glachancecmaisonneuve <[email protected]> Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Travis Plunk (TravisEz13)
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see updated comments
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsCo-Authored-By: glachancecmaisonneuve <[email protected]> Co-Authored-By: glachancecmaisonneuve <[email protected]>
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
Nevermind. There is no way to get an unexpanded path out of the registry save for a direct call to [Microsoft.Win32.RegistryKey]::GetKey. My part is done right? I don't have to add anything for this to eventually go through? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| (-not ($Path.StartsWith($env:LOCALAPPDATA)))) { | ||
| try { | ||
| [string] $KeyName = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' | ||
| Add-Path([Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($KeyName), $Path) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
should we return after this if Add-Path was successful?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return $False | ||
| } | ||
|
|
||
| Function Add-Path([Microsoft.Win32.RegistryKey] $Key, [string] $Path) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Add a description of what each function does and the expected values of the parameters.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| Function Test-PathInRegistryPath([string] $Path) { | ||
| #Remove ending DirectorySeparatorChar for comparison purposes |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
NIT: convention is to have a space after the # in a comment
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| #Remove ending DirectorySeparatorChar for comparison purposes | ||
| $Path = [System.Environment]::ExpandEnvironmentVariables([regex]::Replace($Path, '\\;$|\\$', '')); | ||
| $InstalledPaths = @() | ||
| #[System.Environment]::GetEnvironmentVariable automatically expands all variables |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
NIT: convention is to have a newline before a comment
(NIT = minor issues not blocking the PR)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
blocks of comments just have one newline before the first comment
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the contribution. This fixes a regression in the code I introduced. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
saving the path is needed even in the build systems we use. They often spawn new processes from a central build orchestrator. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, We were focusing on the release of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry it's the end of the term and I haven't had much time at all. I'll implement the requested changes as soon as i'm able |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- Test-PathInRegistryPath was in fact a validator - Update-Path should not be a function but in the script's body - Add-PathToSettings was the only real function Added: - parameter validation - function documentation Other: - formatting changes as requested
|
The script is failing on windows. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for your contribution. Feel free to ping me if I lose you PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This PR is a re-implementation of the -AddToPath switch in tools/install-powershell.ps1, without the side-effects the current implementation has. The changes only affects windows users.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.