aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2023-03-03 13:49:56 +0100
committerGitHub <noreply@github.com>2023-03-03 13:49:56 +0100
commit0507462c0626d19b59b78e490b7b203df29e7bb0 (patch)
treeab53f035b878cd54be8cd93031c4669eba2201a5 /src/libutil/util.cc
parent19c1a4699b2a19e38c9d3953e75c029b4faee2ce (diff)
parentdc8820c71f841df49568099bf3889c7cfb2d92a9 (diff)
Merge pull request #7918 from zimbatm/fix-empty-nix-store-env
treat empty NIX_STORE_DIR env vars as unset
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index e4af702a3..17ccf3554 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -54,6 +54,11 @@ std::optional<std::string> getEnv(const std::string & key)
return std::string(value);
}
+std::optional<std::string> getEnvNonEmpty(const std::string & key) {
+ auto value = getEnv(key);
+ if (value == "") return {};
+ return value;
+}
std::map<std::string, std::string> getEnv()
{