always source settings of old agent, if applicable

Fixes the problem that the `GPG_AGENT_INFO` environment variable is only exported,
if no `gpg-agent` instance is already running.
This commit is contained in:
Marvin Frommhold 2016-09-02 11:45:58 +02:00 committed by GitHub
commit d35846083f

View file

@ -14,8 +14,6 @@ function start_agent_withssh {
export SSH_AGENT_PID export SSH_AGENT_PID
} }
# check if another agent is running
if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
# source settings of old agent, if applicable # source settings of old agent, if applicable
if [ -f "${GPG_ENV}" ]; then if [ -f "${GPG_ENV}" ]; then
. ${GPG_ENV} > /dev/null . ${GPG_ENV} > /dev/null
@ -24,8 +22,9 @@ if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
export SSH_AGENT_PID export SSH_AGENT_PID
fi fi
# check again if another agent is running using the newly sourced settings # check if another agent is running
if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
# check for existing ssh-agent # check for existing ssh-agent
if ssh-add -l > /dev/null 2> /dev/null; then if ssh-add -l > /dev/null 2> /dev/null; then
# ssh-agent running, start gpg-agent without ssh support # ssh-agent running, start gpg-agent without ssh support
@ -35,7 +34,6 @@ if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
start_agent_withssh; start_agent_withssh;
fi fi
fi fi
fi
GPG_TTY=$(tty) GPG_TTY=$(tty)
export GPG_TTY export GPG_TTY