From 3e88b8bcdcb014642da4e57eb0af5df31b5b8161 Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Wed, 27 Aug 2014 21:01:57 -0700 Subject: [PATCH] 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 grep to a value that will never match if unset, i.e. -1. Signed-off-by: Sorin Ionescu --- modules/ssh/init.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ssh/init.zsh b/modules/ssh/init.zsh index 608e34e..5729dc6 100644 --- a/modules/ssh/init.zsh +++ b/modules/ssh/init.zsh @@ -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