* Fix env diff for variables containing leading/trailing whitespace
* Run whole script in 'clean' (non-direnv) environment (fixes prepending/appending)
master
0xee 2019-11-27 14:03:56 +01:00
parent cd10903ba1
commit ac83f17b77
1 changed files with 7 additions and 2 deletions

View File

@ -30,14 +30,14 @@ diffEnvs() {
local old="$1"
local new="$2"
while read -r -d '' line; do
while IFS= read -r -d '' line; do
name=$(tr -d '\0' <<<"$line" | head -n1 | cut -f1 -d'=')
if ! getByName "$name" "$new" >/dev/null; then
echo "export -n '${name}'"
fi
done <"$old"
while read -rd $'\0' line; do
while IFS= read -rd $'\0' line; do
name=$(tr -d '\0' <<<"$line" | head -n1 | cut -f1 -d'=')
if getByName "$name" "$old" >/dev/null; then
# found in old env, check if values match
@ -77,6 +77,11 @@ cacheFile=$(getCacheFilePath)
case $cmd in
reload|r)
if [[ -n $DIRENV_DIR ]]; then
# run self in clean environment (i.e. outside of the current direnv
# environment)
exec direnv exec /proc "${BASH_SOURCE[0]}" "$@"
fi
echo "Re-creating cache"
mkdir -p "$(dirname ${cacheFile})"
dumpEnv > "${cacheFile}.pre"