aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-08-10 16:02:42 -0700
committerJade Lovelace <lix@jade.fyi>2024-08-10 16:07:21 -0700
commit292567e0b0a4681eb8ca803c26293d70857fe387 (patch)
tree9ab98e53bafb1b91bcf41fe3b335d2a2568fb3ca /src/libmain/shared.cc
parent3775b6ac88720ab10237bab4817313c920daffcb (diff)
fix: check if it is a Real terminal, not just if it is a terminal
This will stop printing stuff to dumb terminals that they don't support. I've overall audited usage of isatty and replaced the ones with intent to mean "is a Real terminal" with checking for that. I've also caught a case of carelessly assuming "is a tty" means "should be colour" in nix-env. Change-Id: I6d83725d9a2d932ac94ff2294f92c0a1100d23c9
Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index a407c647f..018e34509 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -5,9 +5,9 @@
#include "signals.hh"
#include "loggers.hh"
#include "current-process.hh"
+#include "terminal.hh"
#include <algorithm>
-#include <cctype>
#include <exception>
#include <iostream>
@@ -347,7 +347,7 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
RunPager::RunPager()
{
- if (!isatty(STDOUT_FILENO)) return;
+ if (!isOutputARealTerminal(StandardOutputStream::Stdout)) return;
char * pager = getenv("NIX_PAGER");
if (!pager) pager = getenv("PAGER");
if (pager && ((std::string) pager == "" || (std::string) pager == "cat")) return;