1
0
Fork 0

Fix gpg module condition

Fix gpg module grep regex expression, because of matching failed when `GPG_AGENT_INFO` is empty. 

And use gpgconf to get socket file instead of `$GNUPGHOME`.

fix: sorin-ionescu/prezto#1681
pull/1682/head
Vonfry 6 years ago committed by GitHub
parent 4abbc55721
commit d66a0998d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,14 +13,16 @@ fi
# Set the default paths to gpg-agent files.
_gpg_agent_conf="${GNUPGHOME:-$HOME/.gnupg}/gpg-agent.conf"
_gpg_agent_env="${TMPDIR:-/tmp}/gpg-agent.env.$UID"
_gpg_agent_socket="$(gpgconf --list-dir | grep "agent-socket:.*" | sed "s/agent-socket://")"
# Load environment variables from previous run
source "$_gpg_agent_env" 2> /dev/null
# Start gpg-agent if not started.
if [[ -z "$GPG_AGENT_INFO" && ! -S "${GNUPGHOME:-$HOME/.gnupg}/S.gpg-agent" ]]; then
if [[ -z "$GPG_AGENT_INFO" && ! -S ${_gpg_agent_socket}" ]]; then
# Start gpg-agent if not started.
if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${${${(s.:.)GPG_AGENT_INFO}[2]}:--1} gpg-agent"; then
if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "^[0-9]* gpg-agent$"; then
eval "$(gpg-agent --daemon | tee "$_gpg_agent_env")"
fi
fi

Loading…
Cancel
Save