From ba87b08f8529e4d9f8c58d8c625152058ceadb75 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 22 Nov 2019 16:06:44 +0100 Subject: getEnv(): Return std::optional This allows distinguishing between an empty value and no value. --- src/nix/doctor.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nix/doctor.cc') diff --git a/src/nix/doctor.cc b/src/nix/doctor.cc index 795236c5f..481c93b45 100644 --- a/src/nix/doctor.cc +++ b/src/nix/doctor.cc @@ -68,7 +68,7 @@ struct CmdDoctor : StoreCommand { PathSet dirs; - for (auto & dir : tokenizeString(getEnv("PATH"), ":")) + for (auto & dir : tokenizeString(getEnv("PATH").value_or(""), ":")) if (pathExists(dir + "/nix-env")) dirs.insert(dirOf(canonPath(dir + "/nix-env", true))); @@ -87,7 +87,7 @@ struct CmdDoctor : StoreCommand { PathSet dirs; - for (auto & dir : tokenizeString(getEnv("PATH"), ":")) { + for (auto & dir : tokenizeString(getEnv("PATH").value_or(""), ":")) { Path profileDir = dirOf(dir); try { Path userEnv = canonPath(profileDir, true); -- cgit v1.2.3