From 7b8580be9c84397a1bb90e3fb2cf759d683df35f Mon Sep 17 00:00:00 2001 From: Emily Frost Date: Wed, 3 Aug 2022 21:31:24 -0500 Subject: [PATCH] Fixed a bug in which get-ssh-agent would not actually source the env file when run the first time. --- functions/get-ssh-agent | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/get-ssh-agent b/functions/get-ssh-agent index c23ed1d..c8e6353 100755 --- a/functions/get-ssh-agent +++ b/functions/get-ssh-agent @@ -13,9 +13,11 @@ else fi function _start_new_ssh_agent () { + ssh_agent_file=$1 killall ssh-agent # start a new ssh-agent and write its output to the env file. - ssh-agent | grep -v echo >&"$ssh_agent_env_file" + ssh-agent | grep -v echo >& "$ssh_agent_file" + source "$ssh_agent_file" echo "New ssh-agent started." ssh-add } @@ -27,9 +29,9 @@ if [[ -e "$ssh_agent_env_file" ]]; then echo "Existing ssh-agent environment configured with pid ${SSH_AGENT_PID}." else echo "Existing ssh-agent appears to be dead." - _start_new_ssh_agent + _start_new_ssh_agent "$ssh_agent_env_file" fi else echo "No existing ssh-agent found." - _start_new_ssh_agent + _start_new_ssh_agent "$ssh_agent_env_file" fi