Skip to content

Commit

Permalink
Set default SSH_AGENT_PID for grep
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kylemanna authored and sorin-ionescu committed Oct 6, 2014
1 parent e892d7f commit 3e88b8b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/ssh/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3e88b8b

Please sign in to comment.