Apply kati output rewriting to dumpvars
This way we strip out ANSI codes when using dumb terminals. It's likely
overkill to use katiRewriteOutput, but we should rarely see any output
on stderr while dumping variables. This also lets us turn on kati_stats.
Bug: 71729611
Test: lunch missing-eng (colored error)
Test: lunch missing-eng 2>&1 | cat (non-colored)
Test: TERM=dumb lunch missing-eng (non-colored)
Change-Id: Ic63fd42d82a4a64e5c68aecd9ae0f242a0d703f1
diff --git a/ui/build/kati.go b/ui/build/kati.go
index 7bb721d..e4715bb 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -115,6 +115,7 @@
func katiRewriteOutput(ctx Context, pipe io.ReadCloser) {
haveBlankLine := true
smartTerminal := ctx.IsTerminal()
+ errSmartTerminal := ctx.IsErrTerminal()
scanner := bufio.NewScanner(pipe)
for scanner.Scan() {
@@ -155,7 +156,7 @@
// that message instead of overwriting it.
fmt.Fprintln(ctx.Stdout())
haveBlankLine = true
- } else if !smartTerminal {
+ } else if !errSmartTerminal {
// Most editors display these as garbage, so strip them out.
line = string(stripAnsiEscapes([]byte(line)))
}