1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

Clean up env var logic in preparation for Windows

It's a little weird we don't check the return status for these, but
changing that would introduce risk so I did not.

Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
This commit is contained in:
John Ericson 2024-04-04 12:48:54 -04:00
parent 6b889e0588
commit ef2d10f7e7
8 changed files with 32 additions and 20 deletions

View file

@ -308,7 +308,7 @@ void printVersion(const std::string & programName)
void showManPage(const std::string & name)
{
restoreProcessContext();
setenv("MANPATH", settings.nixManDir.c_str(), 1);
setEnv("MANPATH", settings.nixManDir.c_str());
execlp("man", "man", name.c_str(), nullptr);
throw SysError("command 'man %1%' failed", name.c_str());
}
@ -369,7 +369,7 @@ RunPager::RunPager()
if (dup2(toPager.readSide.get(), STDIN_FILENO) == -1)
throw SysError("dupping stdin");
if (!getenv("LESS"))
setenv("LESS", "FRSXMK", 1);
setEnv("LESS", "FRSXMK");
restoreProcessContext();
if (pager)
execl("/bin/sh", "sh", "-c", pager, nullptr);