From 9e7ff8c22687d0243898f85fbc56217a29cd0bb1 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Tue, 28 Jun 2016 23:09:07 +0200 Subject: [PATCH] Add guards before exporting the GPG Agent env variables. --- .bashrc | 6 +++--- .zshrc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.bashrc b/.bashrc index dca9acf..5cd1ea9 100644 --- a/.bashrc +++ b/.bashrc @@ -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" diff --git a/.zshrc b/.zshrc index c48af36..bdc58ea 100644 --- a/.zshrc +++ b/.zshrc @@ -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"