From f6fc817e845670b99dfbbe5c7f7a575eef49ca8c Mon Sep 17 00:00:00 2001 From: 0xee Date: Wed, 27 Nov 2019 15:05:32 +0100 Subject: [PATCH] Ignore variables used by direnv All variables matching DIRENV_* are excluded to not influence direnv behavior. --- direnv-cache | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/direnv-cache b/direnv-cache index f0a4972..6350657 100755 --- a/direnv-cache +++ b/direnv-cache @@ -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" }