diff options
author | matthew <matthewkenigsberg@gmail.com> | 2019-11-04 18:40:25 -0600 |
---|---|---|
committer | matthew <matthewkenigsberg@gmail.com> | 2019-11-07 17:22:16 -0600 |
commit | 693e8b1286dc3f39eb00871c91aaf96773e24a68 (patch) | |
tree | bffad36dc859fcc2e540d654dc6240e1c78d145a /src/nix/run.cc | |
parent | d2438f86d50399467b42284a0ba8f74e13b1defe (diff) |
changes
Diffstat (limited to 'src/nix/run.cc')
-rw-r--r-- | src/nix/run.cc | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/nix/run.cc b/src/nix/run.cc index 33e821162..d65a642c2 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -24,7 +24,7 @@ struct RunCommon : virtual Command { void runProgram(ref<Store> store, const std::string & program, - const Strings & args, char** env = environ) + const Strings & args) { stopProgressBar(); @@ -46,12 +46,12 @@ struct RunCommon : virtual Command Strings helperArgs = { chrootHelperName, store->storeDir, store2->realStoreDir, program }; for (auto & arg : args) helperArgs.push_back(arg); - execve(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data(), env); + execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data()); throw SysError("could not execute chroot helper"); } - execvpe(program.c_str(), stringsToCharPtrs(args).data(), env); + execvp(program.c_str(), stringsToCharPtrs(args).data()); throw SysError("unable to execute '%s'", program); } @@ -127,7 +127,7 @@ struct CmdRun : InstallablesCommand, RunCommon }; } - char** newEnviron() { + void setNewEnviron() { if (ignoreEnvironment) { if (!unset.empty()) @@ -138,7 +138,7 @@ struct CmdRun : InstallablesCommand, RunCommon if (val) stringEnv.emplace_back(fmt("%s=%s", var.c_str(), val)); } - return stringsToCharPtrs(stringEnv).data(); + environ = stringsToCharPtrs(stringEnv).data(); } else { if (!keep.empty()) @@ -146,8 +146,6 @@ struct CmdRun : InstallablesCommand, RunCommon for (const auto & var : unset) unsetenv(var.c_str()); - - return environ; } } @@ -162,9 +160,9 @@ struct CmdRun : InstallablesCommand, RunCommon std::queue<Path> todo; for (auto & path : outPaths) todo.push(path); - Strings unixPath; - if (!ignoreEnvironment || keep.find("PATH") != keep.end()) - unixPath = tokenizeString<Strings>(getEnv("PATH"), ":"); + setNewEnviron(); + + auto unixPath = tokenizeString<Strings>(getEnv("PATH"), ":"); while (!todo.empty()) { Path path = todo.front(); @@ -182,16 +180,11 @@ struct CmdRun : InstallablesCommand, RunCommon } setenv("PATH", concatStringsSep(":", unixPath).c_str(), 1); - if (ignoreEnvironment) { - keep.emplace("PATH"); - } else { - unset.erase("PATH"); - } Strings args; for (auto & arg : command) args.push_back(arg); - runProgram(store, *command.begin(), args, newEnviron()); + runProgram(store, *command.begin(), args); } }; |