Move ssh_agent_is_started to its own function. Close #1.

This commit is contained in:
Daniel Perez 2015-11-12 06:46:41 +09:00
parent 5aa699d465
commit ceeb86bbcc
3 changed files with 14 additions and 8 deletions

View File

@ -0,0 +1,12 @@
function __ssh_agent_is_started -d "check if ssh agent is already started"
if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
source $SSH_ENV > /dev/null
end
if test -z "$SSH_AGENT_PID"
return 1
end
ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep ssh-agent > /dev/null
return $status
end

View File

@ -1,4 +1,4 @@
function __ssh_agent_start
function __ssh_agent_start -d "start a new ssh agent"
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
chmod 600 $SSH_ENV
source $SSH_ENV > /dev/null

View File

@ -2,12 +2,6 @@ if test -z "$SSH_ENV"
setenv SSH_ENV $HOME/.ssh/environment
end
if test -z "$SSH_AGENT_PID"
if test -f $SSH_ENV
source $SSH_ENV > /dev/null
end
ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep ssh-agent > /dev/null
if test $status -ne 0
if not __ssh_agent_is_started
__ssh_agent_start
end
end