#autoload local giveup='Cannot check validity of ssh-agent settings; assuming OK.' if ( ! true ); then echo 'zsh has ( ! true ) negated subshell bug!' # Have rewritten the below so this doesn't matter. Still # nice to be alerted to it now and again though. # echo $giveup # return 0 fi if [[ -z "$SSH_AGENT_PID" ]]; then echo '$SSH_AGENT_PID not set.' return 1 fi if [[ -z "$SSH_AUTH_SOCK" ]]; then echo '$SSH_AUTH_SOCK not set.' return 1 fi if ! [[ -e /proc ]]; then echo "/proc didn't exist!" echo $giveup return 0 fi if [[ ! -e /proc/$SSH_AGENT_PID ]]; then echo "\$SSH_AGENT_PID set to non-existent pid ($SSH_AGENT_PID)." return 1 fi if [[ ! -e /proc/$SSH_AGENT_PID/cmdline ]]; then echo "/proc/$SSH_AGENT_PID/cmdline doesn't exist!" return 1 fi if [[ ! -S $SSH_AUTH_SOCK ]]; then echo "\$SSH_AUTH_SOCK set to invalid socket ($SSH_AUTH_SOCK)." return 1 fi grep -q ssh-agent /proc/$SSH_AGENT_PID/cmdline