1
0
Fork 0

ssh: Set default SSH_AGENT_PID for grep

* If `SSH_AGENT_PID` is unset, grep will succeed if another ssh-agent is
  running as it will match the string ` ssh-agent` where the PID was an
  empty string.
* Set a default value for the grep to a value that will never match if
  unset, i.e. -1.
pull/662/head
Kyle Manna 10 years ago
parent bf9dbfd5b9
commit 025cb2d2e7

@ -25,7 +25,7 @@ if [[ ! -S "$SSH_AUTH_SOCK" ]]; then
source "$_ssh_agent_env" 2> /dev/null
# Start ssh-agent if not started.
if ! ps -U "$USER" -o pid,ucomm | grep -q "${SSH_AGENT_PID} ssh-agent"; then
if ! ps -U "$USER" -o pid,ucomm | grep -q -- "${SSH_AGENT_PID:--1} ssh-agent"; then
eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")"
fi
fi

Loading…
Cancel
Save