Skip to content

Commit

Permalink
Stub out RunPager definition rather than call sites
Browse files Browse the repository at this point in the history
  • Loading branch information
puffnfresh authored and Ericson2314 committed Mar 22, 2024
1 parent 93ec39a commit f7837c6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
subs.push_front(state->store);

bool foundLog = false;
#ifndef __WIN32
RunPager pager;
#endif
for (auto & sub : subs) {
auto * logSubP = dynamic_cast<LogStore *>(&*sub);
if (!logSubP) {
Expand Down
6 changes: 4 additions & 2 deletions src/libmain/shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
return 0;
}

#ifndef __WIN32
RunPager::RunPager()
{
if (!isatty(STDOUT_FILENO)) return;
Expand All @@ -375,6 +374,7 @@ RunPager::RunPager()

stopProgressBar();

#ifndef __WIN32
Pipe toPager;
toPager.create();

Expand All @@ -396,11 +396,13 @@ RunPager::RunPager()
std_out = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 0);
if (dup2(toPager.writeSide.get(), STDOUT_FILENO) == -1)
throw SysError("dupping standard output");
#endif
}


RunPager::~RunPager()
{
#ifndef __WIN32
try {
if (pid != -1) {
std::cout.flush();
Expand All @@ -410,8 +412,8 @@ RunPager::~RunPager()
} catch (...) {
ignoreException();
}
}
#endif
}


PrintFreed::~PrintFreed()
Expand Down
4 changes: 2 additions & 2 deletions src/libmain/shared.hh
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ void showManPage(const std::string & name);
* terminal and $PAGER is set. Standard output is redirected to the
* pager.
*/
#ifndef __WIN32
class RunPager
{
public:
RunPager();
~RunPager();

private:
#ifndef __WIN32
Pid pid;
int std_out;
};
#endif
};

extern volatile ::sig_atomic_t blockInt;

Expand Down
2 changes: 0 additions & 2 deletions src/nix/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ struct CmdLog : InstallableCommand
}, b.path.raw());
auto path = resolveDerivedPath(*store, *oneUp);

#ifndef __WIN32
RunPager pager;
#endif
for (auto & sub : subs) {
auto * logSubP = dynamic_cast<LogStore *>(&*sub);
if (!logSubP) {
Expand Down
2 changes: 0 additions & 2 deletions src/nix/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)

auto markdown = state.forceString(*attr->value, noPos, "while evaluating the lowdown help text");

#ifndef __WIN32
RunPager pager;
#endif
std::cout << renderMarkdownToTerminal(markdown) << "\n";
}

Expand Down
2 changes: 0 additions & 2 deletions src/nix/why-depends.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
}
};

#ifndef __WIN32
RunPager pager;
#endif
try {
if (!precise) {
logger->cout("%s", store->printStorePath(graph.at(packagePath).path));
Expand Down

0 comments on commit f7837c6

Please sign in to comment.