From dc25210d889ebbcdfe96bd814a355961e80bccb3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 9 Jun 2022 09:38:04 +0200 Subject: Keep color disabled if APT::Color was set to false Support for envvar NO_COLOR was added in 2.3.11, but with our own options we can also be a tiny bit more sensible in not overriding an explicit choice to disable colors. References: 400a6895566b67d70bcde43dc8a1cc1c7121f87d --- apt-private/private-output.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 04cb148ba..03fbe47e1 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -86,9 +86,9 @@ bool InitOutput(std::basic_streambuf * const out) /*{{{*/ SigWinch(0); } - if(!isatty(1) || getenv("NO_COLOR") != nullptr) + if (isatty(STDOUT_FILENO) == 0 || not _config->FindB("APT::Color", true) || getenv("NO_COLOR") != nullptr) { - _config->Set("APT::Color", "false"); + _config->Set("APT::Color", false); _config->Set("APT::Color::Highlight", ""); _config->Set("APT::Color::Neutral", ""); } else { -- cgit v1.2.3-70-g09d2