Improve filtering of ANSI escape sequences in build logs

All ANSI sequences except color setting are now filtered out. In
particular, terminal resets (such as from NixOS VM tests) are filtered
out.

Also, fix the completely broken tab character handling.
This commit is contained in:
Eelco Dolstra 2018-02-07 15:19:10 +01:00
parent cfdfad5c34
commit 84989d3af2
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
6 changed files with 53 additions and 71 deletions

View file

@ -388,10 +388,12 @@ void ignoreException();
#define ANSI_BLUE "\e[34;1m"
/* Filter out ANSI escape codes from the given string. If nixOnly is
set, only filter escape codes generated by Nixpkgs' stdenv (used to
denote nesting etc.). */
string filterANSIEscapes(const string & s, bool nixOnly = false);
/* Truncate a string to 'width' printable characters. Certain ANSI
escape sequences (such as colour setting) are copied but not
included in the character count. Other ANSI escape sequences are
filtered. Also, tabs are expanded to spaces. */
std::string filterANSIEscapes(const std::string & s,
unsigned int width = std::numeric_limits<unsigned int>::max());
/* Base64 encoding/decoding. */