Stop Get-Process from adding exceptions to $Error when checking if pageant / ssh-agent aren't running#162
Conversation
Updating the Get-Process call in GitUtils.ps1 so exceptions aren't added to the global $Error array This occurs when pageant or ssh-agent aren't running, and therefore there is no process / pid to retrieve. However this is a valid scenario so shouldn't be added to the global $Error array. Also being more explicit with the check of the returned value from Get-Process
|
posh-git still works with V2, right? |
|
The Ignore flag was introduced in V3 which has been available since mid 2012 for Windows 7, Windows Server 2008 / 2008 R2 and built into Windows 8 / Windows Server 2012. You are correct currently the version check in posh-git is set for V2 (install.ps1): if($PSVersionTable.PSVersion.Major -lt 2) {
Write-Warning "posh-git requires PowerShell 2.0 or better; you have version $($Host.Version)."
return
}It depends on if you wish to maintain support for V2 or considering the length of time V3 has been available allowing posh-git to make use of V3 functionality. If you want to maintain support for V2 would a change like this be appropriate: Get-Process | ? { $_.Name -eq 'pageant' } Then there are no errors generated at all as we filter the list of all processes for the one we are looking for. |
This reverts commit 22d1fc4.
Changing the identification of the pageant / ssh-agent process so an error being thrown and silently ignored is not an expected scenario and allows real errors from calling Get-Process to be seen
|
@lzybkr Any feedback on this proposed change? |
|
You've summed it up nicely. I have no idea how many people who use posh-git also use V2. I imagine that number is > 0, so unless there is a compelling reason to force the use of V3, I'd use your filter approach. I submitted similar changes to posh-git for similar reasons. |
Stop Get-Process from adding exceptions to $Error when checking if pageant / ssh-agent aren't running
This isn't the first time this has come up... Opened #163 to put V2 behind us. In the meantime the filter approach works for me - thanks! |
Merge pull request dahlbyk#162 from paulmarsy/master
Revert "Merge pull request dahlbyk#162 from paulmarsy/master"
Updating the Get-Process call in GitUtils.ps1 so exceptions aren't added to the global $Error array
This occurs when pageant or ssh-agent aren't running, and therefore there is no process / pid to retrieve. However this is a valid scenario so shouldn't be added to the global $Error array.
Also being more explicit with the check of the returned value from Get-Process