1
0
mirror of https://github.com/Tarrasch/zsh-autoenv.git synced 2024-11-22 15:30:59 +02:00

doc / small refactoring according to feedback

This commit is contained in:
Daniel Hahler 2014-11-16 11:39:10 +01:00
parent 71ed15679b
commit 64bbb2f305

View File

@ -56,6 +56,7 @@ _dotenv_read_answer() {
echo $answer echo $answer
} }
# Args: 1: absolute path to env file (resolved symlinks).
_dotenv_check_authorized_env_file() { _dotenv_check_authorized_env_file() {
if ! [[ -f $1 ]]; then if ! [[ -f $1 ]]; then
return 1 return 1
@ -112,6 +113,7 @@ _dotenv_chpwd_handler() {
fi fi
if ! [[ -f $env_file ]] && [[ $DOTENV_LOOK_UPWARDS == 1 ]]; then if ! [[ -f $env_file ]] && [[ $DOTENV_LOOK_UPWARDS == 1 ]]; then
# Look for files in parent dirs, using an extended Zsh glob.
setopt localoptions extendedglob setopt localoptions extendedglob
local m local m
m=((../)#${DOTENV_FILE_ENTER}(N)) m=((../)#${DOTENV_FILE_ENTER}(N))
@ -126,12 +128,14 @@ _dotenv_chpwd_handler() {
return return
fi fi
# Load the env file only once. # Load the env file only once: check if $env_file's parent
if (( ${+_dotenv_stack_entered[(r)${env_file:A:h}]} )); then # is in $_dotenv_stack_entered.
local env_file_dir=${env_file:A:h}
if (( ${+_dotenv_stack_entered[(r)${env_file_dir}]} )); then
return return
fi fi
_dotenv_stack_entered+=(${env_file:A:h}) _dotenv_stack_entered+=(${env_file_dir})
_dotenv_source $env_file enter _dotenv_source $env_file enter
} }