mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-11-22 23:40:58 +02:00
Fix _autoenv_get_file_upwards for older Zsh
This commit is contained in:
parent
d9ff71ac1d
commit
6d8141d290
29
autoenv.zsh
29
autoenv.zsh
@ -181,15 +181,26 @@ _autoenv_source() {
|
|||||||
_autoenv_get_file_upwards() {
|
_autoenv_get_file_upwards() {
|
||||||
local look_from=${1:-$PWD}
|
local look_from=${1:-$PWD}
|
||||||
local look_for=${2:-$AUTOENV_FILE_ENTER}
|
local look_for=${2:-$AUTOENV_FILE_ENTER}
|
||||||
# Look for files in parent dirs, using an extended Zsh glob.
|
|
||||||
setopt localoptions extendedglob
|
# Manually look in parent dirs. An extended Zsh glob should use Y1 for
|
||||||
local m
|
# performance reasons, which is only available in zsh-5.0.5-146-g9381bb6.
|
||||||
# Y1: short-circuit: first match.
|
local last
|
||||||
# :A: absolute path, resolving symlinks.
|
local parent_dir="$look_from/.."
|
||||||
m=($look_from/(../)##${look_for}(NY1:A))
|
while true; do
|
||||||
if (( $#m )); then
|
parent_dir=${parent_dir:A}
|
||||||
echo $m[1]
|
if [[ $parent_dir == $last ]]; then
|
||||||
fi
|
break
|
||||||
|
fi
|
||||||
|
parent_file="${parent_dir}/${look_for}"
|
||||||
|
|
||||||
|
if [[ -f $parent_file ]]; then
|
||||||
|
echo $parent_file
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
last=$parent_dir
|
||||||
|
parent_dir="${parent_dir}/.."
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user