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/command.cc | 2 +- src/nix/doctor.cc | 4 ++-- src/nix/run.cc | 2 +- src/nix/upgrade-nix.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nix') diff --git a/src/nix/command.cc b/src/nix/command.cc index 97c2fcf1c..724f03e5d 100644 --- a/src/nix/command.cc +++ b/src/nix/command.cc @@ -156,7 +156,7 @@ void StorePathCommand::run(ref store) Strings editorFor(const Pos & pos) { - auto editor = getEnv("EDITOR", "cat"); + auto editor = getEnv("EDITOR").value_or("cat"); auto args = tokenizeString(editor); if (pos.line > 0 && ( editor.find("emacs") != std::string::npos || 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); diff --git a/src/nix/run.cc b/src/nix/run.cc index 90b76d666..fd4f92282 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -128,7 +128,7 @@ struct CmdRun : InstallablesCommand std::queue todo; for (auto & path : outPaths) todo.push(path); - auto unixPath = tokenizeString(getEnv("PATH"), ":"); + auto unixPath = tokenizeString(getEnv("PATH").value_or(""), ":"); while (!todo.empty()) { Path path = todo.front(); diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc index 35c44a70c..6c9e37d04 100644 --- a/src/nix/upgrade-nix.cc +++ b/src/nix/upgrade-nix.cc @@ -106,7 +106,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand { Path where; - for (auto & dir : tokenizeString(getEnv("PATH"), ":")) + for (auto & dir : tokenizeString(getEnv("PATH").value_or(""), ":")) if (pathExists(dir + "/nix-env")) { where = dir; break; -- cgit v1.2.3 From 313106d5491c7c6279f3c962348462ca04cd2e0e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 26 Nov 2019 21:07:44 +0100 Subject: Fix clang warnings --- src/nix/command.hh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nix') diff --git a/src/nix/command.hh b/src/nix/command.hh index 26c15e646..2db22dba2 100644 --- a/src/nix/command.hh +++ b/src/nix/command.hh @@ -16,6 +16,7 @@ struct Pos; run() method. */ struct Command : virtual Args { + virtual ~Command() { } virtual std::string name() = 0; virtual void prepare() { }; virtual void run() = 0; @@ -58,6 +59,8 @@ typedef std::vector Buildables; struct Installable { + virtual ~Installable() { } + virtual std::string what() = 0; virtual Buildables toBuildables() -- cgit v1.2.3