mirror of https://github.com/sbt/sbt.git
It is possible for downstream dependencies to print or log messages containing ansi escape sequences and/or color codes. In older versions of sbt, these would be printed even if the user had disabled ansi codes or color via the sbt.log.noformat or sbt.color parameters. This commit adds a general api to EscHelpers that strips general ansi codes and color codes independently via flags. We can then use that api to ensure that all bytes written to System.out are stripped of ansi escape and color codes if the terminal properties demand this. The motivation was that JLine 3 will prepend the prompt string with \E[?2004h, which turns on bracketed paste mode (https://en.wikipedia.org/wiki/ANSI_escape_code). If the sbt shell is started with a terminal that doesn't support general ansi escape codes, such as the jEdit shell, ?2004h gets printed to the shell. To fix this, we can strip ansi codes from all output if the terminal doesn't support general ansic codes. This has the additional side effect of any ansi codes that appear in log messages or printlns that are added by non-sbt code will be stripped. It's unlikely that this is all that common. In addition to the JLine use case, I've noticed that utest prints colored output during test runs. Prior to this change, the colored output was present even when sbt was run with `-Dsbt.color=false` and after this change, the colors are correctly stripped. |
||
|---|---|---|
| .. | ||
| util-collection | ||
| util-complete | ||
| util-control | ||
| util-interface/src/main/java/xsbti | ||
| util-logging | ||
| util-logic/src | ||
| util-position/src | ||
| util-relation/src | ||
| util-scripted/src/main | ||