Permalink
Browse files

agent: gpg-agent bugfix, using zpgrep

  • Loading branch information...
1 parent d747ca0 commit c95ab62253d2b9f57634f96a60412b071d78329b @shurizzle shurizzle committed Nov 30, 2012
Showing with 7 additions and 11 deletions.
  1. +7 −11 agent/init.zsh
View
@@ -7,11 +7,9 @@ if is-callable ssh-agent; then
if [[ -s "$env" ]]; then
source "$env" &> /dev/null
- if is-callable pgrep; then
- (( ${$(pgrep -U "$USER" ssh-agent):-0} == SSH_AGENT_PID )) && return 0
- else
- ps -ef | grep -q " $SSH_AGENT_PID .* ssh-agent$" && return 0
- fi
+ local -a ssh_agents
+ ssh_agents=(${(f@)"$(zpgrep -u "$USER" ssh-agent)"})
+ (( $ssh_agents[(I)$SSH_AGENT_PID] )) && return 0
fi
# start ssh-agent and setup the environment
@@ -51,14 +49,12 @@ if is-callable gpg-agent; then
if [[ -s "$env" ]]; then
source "$env" &> /dev/null
- if is-callable pgrep; then
- (( ${$(pgrep -U "$USER" gpg):-0} == SSH_AGENT_PID )) && return 0
- else
- ps -ef | grep -q " $SSH_AGENT_PID .* gpg-agent$" && return 0
- fi
+ local -a gpg_agents
+ gpg_agents=(${(f@)"$(zpgrep -u "$USER" gpg-agent)"})
+ (( $#gpg_agents )) && return 0
fi
- gpg-agent --enable-ssh-support --daemon --write-env-file "$env" &> /dev/null
+ gpg-agent --daemon --write-env-file "$env" &> /dev/null
chmod 600 "$env"
source "$env" &> /dev/null

0 comments on commit c95ab62

Please sign in to comment.