From f7837c67a49abab50b9c524836db0aa2fea71906 Mon Sep 17 00:00:00 2001 From: Brian McKenna Date: Tue, 5 Mar 2024 21:01:38 +0000 Subject: [PATCH] Stub out RunPager definition rather than call sites --- src/libcmd/repl.cc | 2 -- src/libmain/shared.cc | 6 ++++-- src/libmain/shared.hh | 4 ++-- src/nix/log.cc | 2 -- src/nix/main.cc | 2 -- src/nix/why-depends.cc | 2 -- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 2c9e9fbd74fa..5164929c829d 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -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(&*sub); if (!logSubP) { diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 2feff7c504cb..e2803fc027a4 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -365,7 +365,6 @@ int handleExceptions(const std::string & programName, std::function fun) return 0; } -#ifndef __WIN32 RunPager::RunPager() { if (!isatty(STDOUT_FILENO)) return; @@ -375,6 +374,7 @@ RunPager::RunPager() stopProgressBar(); +#ifndef __WIN32 Pipe toPager; toPager.create(); @@ -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(); @@ -410,8 +412,8 @@ RunPager::~RunPager() } catch (...) { ignoreException(); } -} #endif +} PrintFreed::~PrintFreed() diff --git a/src/libmain/shared.hh b/src/libmain/shared.hh index afe560f60fc8..3a00b56503f6 100644 --- a/src/libmain/shared.hh +++ b/src/libmain/shared.hh @@ -84,7 +84,6 @@ void showManPage(const std::string & name); * terminal and $PAGER is set. Standard output is redirected to the * pager. */ -#ifndef __WIN32 class RunPager { public: @@ -92,10 +91,11 @@ public: ~RunPager(); private: +#ifndef __WIN32 Pid pid; int std_out; -}; #endif +}; extern volatile ::sig_atomic_t blockInt; diff --git a/src/nix/log.cc b/src/nix/log.cc index 4c7185831ec3..156004b9f07b 100644 --- a/src/nix/log.cc +++ b/src/nix/log.cc @@ -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(&*sub); if (!logSubP) { diff --git a/src/nix/main.cc b/src/nix/main.cc index a078aa31d373..a06981277f61 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -273,9 +273,7 @@ static void showHelp(std::vector 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"; } diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc index aafc9cdceaf7..e299585ff88e 100644 --- a/src/nix/why-depends.cc +++ b/src/nix/why-depends.cc @@ -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));