Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

force reverse sourcing

  • Loading branch information...
commit 44ee7732d4f7cc1607dfa8a3b9aca1b0be7f20b2 1 parent 166a996
@mpapis mpapis authored
Showing with 16 additions and 6 deletions.
  1. +16 −6 activate.sh
View
22 activate.sh
@@ -1,15 +1,18 @@
#!/usr/bin/env bash
+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="$(dirname $HOME)"
- while read _file
- do
- source "${_file}"
- done < <(
+ _files=( $(
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]
do
_file="$PWD/.env"
@@ -17,8 +20,15 @@ autoenv-init()
then echo "${_file}"
fi
builtin cd ..
- done | sort -r
- )
+ done
+ ) )
+
+ _file=${#_files[@]}
+ while (( _file > 0 ))
+ do
+ source "${_files[_file-__array_offset]}"
+ : $(( _file -= 1 ))
+ done
}
cd()
Please sign in to comment.
Something went wrong with that request. Please try again.