Skip to content

Commit

Permalink
Merge pull request #162 from paulmarsy/master
Browse files Browse the repository at this point in the history
Stop Get-Process from adding exceptions to $Error when checking if pageant / ssh-agent aren't running
  • Loading branch information
dahlbyk committed Nov 13, 2014
2 parents 9d95ed5 + 306eed9 commit 869d4c5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ function Set-TempEnv($key, $value) {
# is a running agent.
function Get-SshAgent() {
if ($env:GIT_SSH -imatch 'plink') {
$pageantPid = Get-Process pageant -ErrorAction SilentlyContinue | Select -ExpandProperty Id
if ($pageantPid) { return $pageantPid }
$pageantPid = Get-Process | Where-Object { $_.Name -eq 'pageant' } | Select -ExpandProperty Id
if ($null -ne $pageantPid) { return $pageantPid }
} else {
$agentPid = $Env:SSH_AGENT_PID
if ($agentPid) {
$sshAgentProcess = Get-Process -Id $agentPid -ErrorAction SilentlyContinue
if ($sshAgentProcess -and ($sshAgentProcess.Name -eq 'ssh-agent')) {
$sshAgentProcess = Get-Process | Where-Object { $_.Id -eq $agentPid -and $_.Name -eq 'ssh-agent' }
if ($null -ne $sshAgentProcess) {
return $agentPid
} else {
setenv 'SSH_AGENT_PID', $null
Expand Down

1 comment on commit 869d4c5

@chaki27
Copy link

@chaki27 chaki27 commented on 869d4c5 Jan 9, 2015

Choose a reason for hiding this comment

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

GitUtils.ps1

Please sign in to comment.