1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 12:48:01 +00:00

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 <sorin.ionescu@gmail.com>
This commit is contained in:
Kyle Manna 2014-08-27 21:01:57 -07:00 committed by Sorin Ionescu
parent e892d7f3c7
commit 3e88b8bcdc

View File

@ -25,7 +25,7 @@ if [[ ! -S "$SSH_AUTH_SOCK" ]]; then
source "$_ssh_agent_env" 2> /dev/null source "$_ssh_agent_env" 2> /dev/null
# Start ssh-agent if not started. # 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")" eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")"
fi fi
fi fi