Ignore variables used by direnv

All variables matching DIRENV_* are excluded to not influence direnv behavior.
master
0xee 2019-11-27 15:05:32 +01:00
parent ac83f17b77
commit f6fc817e84
1 changed files with 13 additions and 9 deletions

View File

@ -32,22 +32,26 @@ diffEnvs() {
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}'"
if ! [[ "$name" = DIRENV_* ]]; then
if ! getByName "$name" "$new" >/dev/null; then
echo "export -n '${name}'"
fi
fi
done <"$old"
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
if ! grep -z "^${line}\$" "$old" >/dev/null; then
# variable has changed
if ! [[ "$name" = DIRENV_* ]]; then
if getByName "$name" "$old" >/dev/null; then
# found in old env, check if values match
if ! grep -z "^${line}\$" "$old" >/dev/null; then
# variable has changed
echo "export ${line@Q}"
fi
else
# variable is new
echo "export ${line@Q}"
fi
else
# variable is new
echo "export ${line@Q}"
fi
done <"$new"
}