Fix error with strict_env

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.
This commit is contained in:
Andrew Marshall 2022-07-22 11:50:55 -04:00
parent 02e11da5fb
commit 2011d81f03

View file

@ -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