Skip to content

Commit

Permalink
ironing this odd lint problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Ira Abramov committed Jan 22, 2025
1 parent bbbf62a commit 4bd2aea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 deletions.
1 change: 1 addition & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ plugins/available/textmate.plugin.bash
plugins/available/todo.plugin.bash
plugins/available/url.plugin.bash
plugins/available/xterm.plugin.bash
plugins/available/z_autoenv.plugin.bash
plugins/available/zoxide.plugin.bash

# tests
Expand Down
68 changes: 33 additions & 35 deletions plugins/available/z_autoenv.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'source into environment when cding to directories'

if [[ -n "${ZSH_VERSION}" ]]
then __array_offset=0
else __array_offset=1
if [[ -n "${ZSH_VERSION}" ]]; then
__array_offset=0
else
__array_offset=1
fi

autoenv_init()
{
typeset target home _file
typeset -a _files
target=$1
home="${HOME%/*}"
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 ..
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
source "${_files[_file-__array_offset]}"
: $(( _file -= 1 ))
done
_file=${#_files[@]}
while ((_file > 0)); do
#shellcheck disable=SC1090
source "${_files[_file - __array_offset]}"
: $((_file -= 1))
done
}

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

0 comments on commit 4bd2aea

Please sign in to comment.