+ if [[ -S "$sock" && $pid > 0 ]] && kill -0 $pid; then
+ echo "Reusing agent pid $pid"
+ export SSH_AUTH_SOCK="$sock"
+ export SSH_AGENT_PID=$pid
+ else
+ # TODO: ensure ssh-agent path looks legit
+ # to avoid unsafe eval?
+ eval `${okc}ssh-agent`
+ echo -n "$SSH_AUTH_SOCK"$'\0'$SSH_AGENT_PID >!$agentfile
+ fi
+ unset okc agentfile sock pid
+} elif [[ -v commands[gpg] && ! -S $_GNUPG_SOCK_DEST && \
+ ( ! -v SSH_AUTH_SOCK || -v DISPLAY ) ]] {
+ export GPG_TTY=$(tty)
+ export PINENTRY_USER_DATA=USE_TTY=$((!${+DISPLAY}))
+ gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null 2>&1
+ gpg-connect-agent /subst /serverpid \
+ '/echo GPG agent pid ${get serverpid}' /bye
+ [[ ! -v SSH_AUTH_SOCK ]] && \
+ export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)