mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Merge pull request #4971 from ylh/master
Respect TERM=dumb more consistently
This commit is contained in:
commit
7a3f43cd58
4 changed files with 11 additions and 2 deletions
|
@ -484,7 +484,7 @@ Logger * makeProgressBar(bool printBuildLogs)
|
|||
{
|
||||
return new ProgressBar(
|
||||
printBuildLogs,
|
||||
isatty(STDERR_FILENO) && getEnv("TERM").value_or("dumb") != "dumb"
|
||||
shouldANSI()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
: printBuildLogs(printBuildLogs)
|
||||
{
|
||||
systemd = getEnv("IN_SYSTEMD") == "1";
|
||||
tty = isatty(STDERR_FILENO);
|
||||
tty = shouldANSI();
|
||||
}
|
||||
|
||||
bool isVerbose() override {
|
||||
|
|
|
@ -1372,6 +1372,12 @@ void ignoreException()
|
|||
}
|
||||
}
|
||||
|
||||
bool shouldANSI()
|
||||
{
|
||||
return isatty(STDERR_FILENO)
|
||||
&& getEnv("TERM").value_or("dumb") != "dumb"
|
||||
&& !getEnv("NO_COLOR").has_value();
|
||||
}
|
||||
|
||||
std::string filterANSIEscapes(const std::string & s, bool filterAll, unsigned int width)
|
||||
{
|
||||
|
|
|
@ -482,6 +482,9 @@ constexpr char treeLast[] = "└───";
|
|||
constexpr char treeLine[] = "│ ";
|
||||
constexpr char treeNull[] = " ";
|
||||
|
||||
/* Determine whether ANSI escape sequences are appropriate for the
|
||||
present output. */
|
||||
bool shouldANSI();
|
||||
|
||||
/* Truncate a string to 'width' printable characters. If 'filterAll'
|
||||
is true, all ANSI escape sequences are filtered out. Otherwise,
|
||||
|
|
Loading…
Reference in a new issue