# This is useful if you want to use a base .autoenv.zsh file for a directory
# subtree.
autoenv_source_parent() {
- local parent_env_file=$(_autoenv_get_file_upwards ${autoenv_env_file:h})
+ local look_until=${1:-/}
+ local parent_env_file=$(_autoenv_get_file_upwards \
+ ${autoenv_env_file:h} ${AUTOENV_FILE_ENTER} $look_until)
if [[ -n $parent_env_file ]] \
&& _autoenv_check_authorized_env_file $parent_env_file; then
return 1
fi
if ! _autoenv_authorized_env_file $1; then
- echo "Attempting to load unauthorized env file!"
- command ls -l $1
- echo ""
- echo "**********************************************"
- echo ""
- cat $1
- echo ""
- echo "**********************************************"
- echo ""
- echo -n "Would you like to authorize it? (type 'yes') "
+ echo "Attempting to load unauthorized env file!" >&2
+ command ls -l $1 >&2
+ echo >&2
+ echo "**********************************************" >&2
+ echo >&2
+ command cat $1 >&2
+ echo >&2
+ echo "**********************************************" >&2
+ echo >&2
+ echo -n "Would you like to authorize it? (type 'yes') " >&2
# echo "Would you like to authorize it?"
# echo "('yes' to allow, 'no' to not being asked again; otherwise ignore it for the shell) "
_autoenv_get_file_upwards() {
local look_from=${1:-$PWD}
local look_for=${2:-$AUTOENV_FILE_ENTER}
+ local look_until=${${3:-/}:A}
# Manually look in parent dirs. An extended Zsh glob should use Y1 for
# performance reasons, which is only available in zsh-5.0.5-146-g9381bb6.
break
fi
+ if [[ $parent_dir == $look_until ]]; then
+ break
+ fi
last=$parent_dir
parent_dir="${parent_dir}/.."
done