From 2011d81f03e26c0a50d8a1836ddfe02c9cfaa441 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 22 Jul 2022 11:50:55 -0400 Subject: [PATCH] Fix error with strict_env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With direnv’s `strict_env`, previously got an error > NIX_BUILD_TOP: unbound variable I tried to adjust the tests to catch this, but unfortunately I could not get it to fail. --- direnvrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/direnvrc b/direnvrc index a25f24a..33c5c32 100644 --- a/direnvrc +++ b/direnvrc @@ -100,7 +100,7 @@ _nix_import_env() { # as it may be garbage collected. # Instead - just remove it immediately. # Use recursive & force as it may not be empty. - if [[ "$NIX_BUILD_TOP" == */nix-shell.* && -d "$NIX_BUILD_TOP" ]]; then + if [[ -n "${NIX_BUILD_TOP+x}" && "$NIX_BUILD_TOP" == */nix-shell.* && -d "$NIX_BUILD_TOP" ]]; then rm -rf "$NIX_BUILD_TOP" fi