use sane dir if $TMPDIR is not set

This commit is contained in:
Matt Hamilton 2015-12-21 20:34:55 -05:00
parent fb549f108a
commit 9302507257

View File

@ -7,8 +7,16 @@ if (( ! ${+commands[ssh-agent]} )); then
return 1 return 1
fi fi
local ssh_env=${TMPDIR:-/tmp}/ssh-agent.env # use a sane temp dir; creating 1k ssh-* files in /tmp is crazy
local ssh_sock=${TMPDIR:-/tmp}/ssh-agent.sock if [[ ${TMPDIR} ]]; then
local ssh_env=${TMPDIR}/ssh-agent.env
local ssh_sock=${TMPDIR}/ssh-agent.sock
else
# create a sane tmp dir at /tmp/username
mkdir -p /tmp/${USER}
local ssh_env=/tmp/${USER}
local ssh_sock=/tmp/${USER}
fi
# start ssh-agent if not already running # start ssh-agent if not already running
if [[ ! -S ${SSH_AUTH_SOCK} ]]; then if [[ ! -S ${SSH_AUTH_SOCK} ]]; then