1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 05:01:48 +02:00

Merge pull request #10131 from intelfx/work/notty

`TERM=dumb` fixes
This commit is contained in:
Théophane Hufschmitt 2024-03-29 13:38:37 +01:00 committed by GitHub
commit 90f5189451
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 28 additions and 18 deletions

View file

@ -52,7 +52,7 @@ public:
: printBuildLogs(printBuildLogs)
{
systemd = getEnv("IN_SYSTEMD") == "1";
tty = shouldANSI();
tty = isTTY();
}
bool isVerbose() override {

View file

@ -7,11 +7,14 @@
namespace nix {
bool shouldANSI()
bool isTTY()
{
return isatty(STDERR_FILENO)
static const bool tty =
isatty(STDERR_FILENO)
&& getEnv("TERM").value_or("dumb") != "dumb"
&& !(getEnv("NO_COLOR").has_value() || getEnv("NOCOLOR").has_value());
return tty;
}
std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int width)

View file

@ -8,7 +8,7 @@ namespace nix {
* Determine whether ANSI escape sequences are appropriate for the
* present output.
*/
bool shouldANSI();
bool isTTY();
/**
* Truncate a string to 'width' printable characters. If 'filterAll'