about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-03-15T15·08+0100
committerEelco Dolstra <edolstra@gmail.com>2018-03-15T15·08+0100
commit486872150638d56483c2bc429ba9e137d9974ee8 (patch)
tree469f6346618c2fbe1eb2e4282ef7e6cc90c01ff5 /src/libutil/util.cc
parent7b8914825a6b02173976eae0ca59053085d4b20a (diff)
Filter ANSI colors when not writing to a terminal
Fixes https://github.com/NixOS/nixpkgs/issues/37114.
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 2391e14a94bd..a60ba8508e31 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1185,7 +1185,7 @@ void ignoreException()
 }
 
 
-std::string filterANSIEscapes(const std::string & s, unsigned int width)
+std::string filterANSIEscapes(const std::string & s, bool filterAll, unsigned int width)
 {
     std::string t, e;
     size_t w = 0;
@@ -1210,7 +1210,7 @@ std::string filterANSIEscapes(const std::string & s, unsigned int width)
                 if (i != s.end() && *i >= 0x40 && *i <= 0x5f) e += *i++;
             }
 
-            if (last == 'm')
+            if (!filterAll && last == 'm')
                 t += e;
         }