From 292567e0b0a4681eb8ca803c26293d70857fe387 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Sat, 10 Aug 2024 16:02:42 -0700 Subject: 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 --- src/libutil/logging.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/libutil/logging.cc') diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc index cbeb7aa36..7d9482814 100644 --- a/src/libutil/logging.cc +++ b/src/libutil/logging.cc @@ -37,7 +37,15 @@ void Logger::warn(const std::string & msg) void Logger::writeToStdout(std::string_view s) { - writeFull(STDOUT_FILENO, filterANSIEscapes(s, !shouldANSI(), std::numeric_limits::max(), false)); + writeFull( + STDOUT_FILENO, + filterANSIEscapes( + s, + !shouldANSI(StandardOutputStream::Stdout), + std::numeric_limits::max(), + false + ) + ); writeFull(STDOUT_FILENO, "\n"); } -- cgit v1.2.3