Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ironing lint problems for the z_autoenv plugin #2279

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions plugins/available/z_autoenv.plugin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,36 @@ else
__array_offset=1
fi

function autoenv_init {
typeset home _file
autoenv_init() {
typeset home _file # target
typeset -a _files
#target=$1
home="${HOME%/*}"

_files=($(
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]; do
_file="$PWD/.env"
if [[ -e "${_file}" ]]; then
echo "${_file}"
fi
builtin cd .. || return
done
))
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]; do
_file="$PWD/.env"
if [[ -e "${_file}" ]]; then
_files+=("${_file}")
fi
builtin cd .. || true
done

_file=${#_files[@]}
while ((_file > 0)); do
# shellcheck disable=SC1090
#shellcheck disable=SC1090
source "${_files[_file - __array_offset]}"
: $((_file -= 1))
done
}

cd() {
local return_code
if builtin cd "$@"; then
autoenv_init
return 0
else
return_code=$?
echo "else?"
return $?
return "$return_code"
fi
}
Loading