Skip to content

Commit d3210d0

Browse files
authored
Merge pull request #2279 from seefood/ira/fix-lint-error
2 parents 9a4af68 + 791d557 commit d3210d0

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

plugins/available/z_autoenv.plugin.bash

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,36 @@ else
99
__array_offset=1
1010
fi
1111

12-
function autoenv_init {
13-
typeset home _file
12+
autoenv_init() {
13+
typeset home _file # target
1414
typeset -a _files
15+
#target=$1
1516
home="${HOME%/*}"
1617

17-
_files=($(
18-
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]; do
19-
_file="$PWD/.env"
20-
if [[ -e "${_file}" ]]; then
21-
echo "${_file}"
22-
fi
23-
builtin cd .. || return
24-
done
25-
))
18+
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]; do
19+
_file="$PWD/.env"
20+
if [[ -e "${_file}" ]]; then
21+
_files+=("${_file}")
22+
fi
23+
builtin cd .. || true
24+
done
2625

2726
_file=${#_files[@]}
2827
while ((_file > 0)); do
29-
# shellcheck disable=SC1090
28+
#shellcheck disable=SC1090
3029
source "${_files[_file - __array_offset]}"
3130
: $((_file -= 1))
3231
done
3332
}
3433

3534
cd() {
35+
local return_code
3636
if builtin cd "$@"; then
3737
autoenv_init
3838
return 0
3939
else
40+
return_code=$?
4041
echo "else?"
41-
return $?
42+
return "$return_code"
4243
fi
4344
}

0 commit comments

Comments
 (0)