fi
if [[ -f ~/.env_auth ]]; then
echo "zsh-autoenv: using deprecated location for AUTOENV_AUTH_FILE." >&2
- echo "Please move it: mv ~/.env_auth ${(D)AUTOENV_AUTH_FILE}." >&2
+ echo "Please move it: mv ~/.env_auth ${(D)AUTOENV_AUTH_FILE}" >&2
AUTOENV_AUTH_FILE=~/.env_auth
fi
fi
echo "Missing file argument for _autoenv_hash_pair!" >&2
return 1
fi
- env_shasum=$(shasum $env_file | cut -d' ' -f1)
+ env_shasum=$(sha1sum $env_file | cut -d' ' -f1)
fi
echo ":${env_file}:${env_shasum}:1"
}
_autoenv_authorize() {
local env_file=${1:A}
_autoenv_deauthorize $env_file
+ [[ -d ${AUTOENV_AUTH_FILE:h} ]] || mkdir -p ${AUTOENV_AUTH_FILE:h}
_autoenv_hash_pair $env_file >>| $AUTOENV_AUTH_FILE
}
local autoenv_to_dir=$PWD
# Source varstash library once.
+ # XXX: pollutes environment with e.g. `stash`, and `autostash` will cause
+ # an overwritten `stash` function to be called!
if [[ -z "$functions[(I)autostash]" ]]; then
- source ${${funcsourcetrace[1]%:*}:h}/lib/varstash
+ if \grep -qE '\b(autostash|autounstash|stash)\b' $autoenv_env_file; then
+ source ${${funcsourcetrace[1]%:*}:h}/lib/varstash
+ fi
# NOTE: Varstash uses $PWD as default for varstash_dir, we might set it to
# ${autoenv_env_file:h}.
fi
fi
# Unstash any autostashed stuff.
- varstash_dir=$prev_dir autounstash
+ if [[ -n "$functions[(I)autostash]" ]]; then
+ varstash_dir=$prev_dir autounstash
+ fi
_autoenv_stack_entered_remove $prev_file
fi