Add guards before exporting the GPG Agent env variables.

This commit is contained in:
Rodolphe Breard 2016-06-28 23:09:07 +02:00
parent 17f6bb0801
commit 9e7ff8c226
2 changed files with 6 additions and 6 deletions

View file

@ -37,9 +37,9 @@ fi
# GPG Agent
export GPG_TTY=$(tty)
export GPG_AGENT_INFO="/run/user/${UID}/gnupg/S.gpg-agent"
export SSH_AUTH_SOCK="/run/user/${UID}/gnupg/S.gpg-agent.ssh"
export SSH_AGENT_PID=$(pgrep -x -u "${USER}" gpg-agent)
[ -f "/run/user/${UID}/gnupg/S.gpg-agent" ] && export GPG_AGENT_INFO="/run/user/${UID}/gnupg/S.gpg-agent"
[ -f "/run/user/${UID}/gnupg/S.gpg-agent.ssh" ] && export SSH_AUTH_SOCK="/run/user/${UID}/gnupg/S.gpg-agent.ssh"
pgrep -x -u "${USER}" gpg-agent >/dev/null 2>&1 && export SSH_AGENT_PID=$(pgrep -x -u "${USER}" gpg-agent)
# Aliases
[ -f "$HOME/.aliases" ] && . "$HOME/.aliases"

6
.zshrc
View file

@ -41,9 +41,9 @@ fi
# GPG Agent
export GPG_TTY=$(tty)
export GPG_AGENT_INFO="/run/user/${UID}/gnupg/S.gpg-agent"
export SSH_AUTH_SOCK="/run/user/${UID}/gnupg/S.gpg-agent.ssh"
export SSH_AGENT_PID=$(pgrep -x -u "${USER}" gpg-agent)
[ -f "/run/user/${UID}/gnupg/S.gpg-agent" ] && export GPG_AGENT_INFO="/run/user/${UID}/gnupg/S.gpg-agent"
[ -f "/run/user/${UID}/gnupg/S.gpg-agent.ssh" ] && export SSH_AUTH_SOCK="/run/user/${UID}/gnupg/S.gpg-agent.ssh"
pgrep -x -u "${USER}" gpg-agent >/dev/null 2>&1 && export SSH_AGENT_PID=$(pgrep -x -u "${USER}" gpg-agent)
# Aliases
[ -f "$HOME/.aliases" ] && . "$HOME/.aliases"