From e52898659db4e34e7f50963f8331e83dedb9fc1b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 15 Apr 2024 13:40:49 +0200 Subject: Also respect an APT_NO_COLOR variable This is easier to discover than APT::Color options and matches best practices. --- apt-private/private-cmndline.cc | 4 ++-- apt-private/private-output.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index 3d6816d57..9b84f2dd5 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -487,8 +487,8 @@ static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/ } if (binary == "apt" || binary == "apt-config") { - if (getenv("NO_COLOR") == nullptr) - _config->CndSet("Binary::apt::APT::Color", true); + if (getenv("NO_COLOR") == nullptr && getenv("APT_NO_COLOR") == nullptr) + _config->CndSet("Binary::apt::APT::Color", true); _config->CndSet("Binary::apt::APT::Output-Version", 30); _config->CndSet("Binary::apt::APT::Cache::Show::Version", 2); _config->CndSet("Binary::apt::APT::Cache::AllVersions", false); diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 95dc740cc..522fba4c6 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -86,7 +86,7 @@ bool InitOutput(std::basic_streambuf * const out) /*{{{*/ SigWinch(0); } - if (isatty(STDOUT_FILENO) == 0 || not _config->FindB("APT::Color", true) || getenv("NO_COLOR") != nullptr) + if (isatty(STDOUT_FILENO) == 0 || not _config->FindB("APT::Color", true) || getenv("NO_COLOR") != nullptr || getenv("APT_NO_COLOR") != nullptr) { _config->Set("APT::Color", false); _config->Set("APT::Color::Highlight", ""); -- cgit v1.2.3-70-g09d2