Kill the ssh-agent only if it was created in this session. Like that the login shell can inherit SSH_AGENT_PID without it killing the agent at the end. For this to work properly it is important that LAUNCHED_SSH_AGENT is not exported, otherwise nested login shells will mess with each other.
3 lines
120 B
Bash
3 lines
120 B
Bash
# Kill ssh-agent if it was created in this session
|
|
! (( LAUNCHED_SSH_AGENT && SSH_AGENT_PID )) || kill "$SSH_AGENT_PID"
|