Added flag so .bash_logout won't try to unregister a socket that didn't register.
This commit is contained in:
parent
8bce5d846c
commit
dae5b0fdaa
3 changed files with 7 additions and 5 deletions
|
@ -18,7 +18,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
|
||||||
_PLATFORM="$(uname -s)"
|
_PLATFORM="$(uname -s)"
|
||||||
|
|
||||||
# Remove the SSH_AUTH_SOCK from the agents file.
|
# 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 && {
|
_lock_agents_file && {
|
||||||
_pop_agent_sock || {
|
_pop_agent_sock || {
|
||||||
echo -e "$(tput setaf 1 || tput AF 1)Failed to clean up agents file!$(tput op)"
|
echo -e "$(tput setaf 1 || tput AF 1)Failed to clean up agents file!$(tput op)"
|
||||||
|
|
|
@ -51,7 +51,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
|
||||||
echo "Connected to ssh-agent."
|
echo "Connected to ssh-agent."
|
||||||
else
|
else
|
||||||
echo -e "$(tput setaf 3)Connected to ssh-agent, but failed to register socket.$(tput op)"
|
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
|
fi
|
||||||
}
|
}
|
||||||
_unlock_agents_file
|
_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."
|
echo "Connected to alternate ssh-agent - you may need to re-add keys."
|
||||||
else
|
else
|
||||||
echo "$(tput setaf 3)Connected to, but failed to register, alternate ssh-agent - you may need to re-add keys.$(tput op)"
|
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
|
fi
|
||||||
}
|
}
|
||||||
_unlock_agents_file
|
_unlock_agents_file
|
||||||
|
@ -87,7 +87,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
|
||||||
echo "Connected to ssh-agent."
|
echo "Connected to ssh-agent."
|
||||||
else
|
else
|
||||||
echo "$(tput setaf 3)Connected to, but failed to register, ssh-agent.$(tput op)"
|
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
|
fi
|
||||||
}
|
}
|
||||||
_unlock_agents_file
|
_unlock_agents_file
|
||||||
|
@ -103,7 +103,7 @@ hash ssh-add ssh-agent >/dev/null 2>&1 && {
|
||||||
echo "Started new ssh-agent."
|
echo "Started new ssh-agent."
|
||||||
else
|
else
|
||||||
echo "$(tput setaf 3)Started, but failed to register, new ssh-agent$(tput op)"
|
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
|
fi
|
||||||
}
|
}
|
||||||
_unlock_agents_file
|
_unlock_agents_file
|
||||||
|
|
2
.bashrc
2
.bashrc
|
@ -15,8 +15,10 @@ _agent_prompt_command() {
|
||||||
_lock_agents_file && {
|
_lock_agents_file && {
|
||||||
if _push_agent_sock; then
|
if _push_agent_sock; then
|
||||||
echo "Connected to alternate ssh-agent - you may need to re-add keys."
|
echo "Connected to alternate ssh-agent - you may need to re-add keys."
|
||||||
|
_SSH_AGENT_REG_FAILED=0
|
||||||
else
|
else
|
||||||
echo "Connected to, but failed to register, alternate ssh-agent - you may need to re-add keys."
|
echo "Connected to, but failed to register, alternate ssh-agent - you may need to re-add keys."
|
||||||
|
_SSH_AGENT_REG_FAILED=1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
_unlock_agents_file
|
_unlock_agents_file
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue