Skip to content

Commit

Permalink
Merge pull request Bash-it#2279 from seefood/ira/fix-lint-error
Browse files Browse the repository at this point in the history
  • Loading branch information
seefood authored Jan 22, 2025
2 parents 9a4af68 + 791d557 commit d3210d0
Showing 1 changed file with 14 additions and 13 deletions.
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
}

0 comments on commit d3210d0

Please sign in to comment.