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 28, 2024
1 parent 3bf32dd commit 70f9fb5
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 @@ -366,7 +366,6 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
}


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

stopProgressBar();

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

Expand All @@ -397,11 +397,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 @@ -411,8 +413,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 @@ -44,9 +44,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 @@ -274,9 +274,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 70f9fb5

Please sign in to comment.