Added flag so .bash_logout won't try to unregister a socket that didn't register.

This commit is contained in:
Darren 'Tadgy' Austin 2019-07-02 22:04:33 +01:00
commit dae5b0fdaa
3 changed files with 7 additions and 5 deletions

View file

@ -18,7 +18,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
_PLATFORM="$(uname -s)"
# Remove the SSH_AUTH_SOCK from the agents file.
[[ ! -z "$SSH_AUTH_SOCK" ]] && {
[[ ! -z "$SSH_AUTH_SOCK" ]] && (( ${_SSH_AGENT_REG_FAILED:-0} == 0 )) && {
_lock_agents_file && {
_pop_agent_sock || {
echo -e "$(tput setaf 1 || tput AF 1)Failed to clean up agents file!$(tput op)"

View file

@ -51,7 +51,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
echo "Connected to ssh-agent."
else
echo -e "$(tput setaf 3)Connected to ssh-agent, but failed to register socket.$(tput op)"
# FIXME: Set marker here that we failed.
_SSH_AGENT_REG_FAILED=1
fi
}
_unlock_agents_file
@ -67,7 +67,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
echo "Connected to alternate ssh-agent - you may need to re-add keys."
else
echo "$(tput setaf 3)Connected to, but failed to register, alternate ssh-agent - you may need to re-add keys.$(tput op)"
# FIXME: Set marker here that we failed.
_SSH_AGENT_REG_FAILED=1
fi
}
_unlock_agents_file
@ -87,7 +87,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
echo "Connected to ssh-agent."
else
echo "$(tput setaf 3)Connected to, but failed to register, ssh-agent.$(tput op)"
# FIXME: Set marker here that we failed.
_SSH_AGENT_REG_FAILED=1
fi
}
_unlock_agents_file
@ -103,7 +103,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
echo "Started new ssh-agent."
else
echo "$(tput setaf 3)Started, but failed to register, new ssh-agent$(tput op)"
# FIXME: Set marker here that we failed.
_SSH_AGENT_REG_FAILED=1
fi
}
_unlock_agents_file

View file

@ -15,8 +15,10 @@ _agent_prompt_command() {
_lock_agents_file && {
if _push_agent_sock; then
echo "Connected to alternate ssh-agent - you may need to re-add keys."
_SSH_AGENT_REG_FAILED=0
else
echo "Connected to, but failed to register, alternate ssh-agent - you may need to re-add keys."
_SSH_AGENT_REG_FAILED=1
fi
}
_unlock_agents_file