summaryrefslogtreecommitdiff
path: root/src/library/scala/util/Properties.scala
diff options
context:
space:
mode:
authorAntoine Gourlay <antoine@gourlay.fr>2017-02-08 16:05:03 +0100
committerAntoine Gourlay <antoine@gourlay.fr>2017-02-21 15:39:26 +0100
commit6411170ede09ace8e5f1f018dcf5661846ed7d27 (patch)
tree986f4f46a7e4de16850c654f19cc39721d9a7717 /src/library/scala/util/Properties.scala
parent76bfb9e0e5f38ce264f2a03490731f5865fa468f (diff)
downloadscala-6411170ede09ace8e5f1f018dcf5661846ed7d27.tar.gz
scala-6411170ede09ace8e5f1f018dcf5661846ed7d27.tar.bz2
scala-6411170ede09ace8e5f1f018dcf5661846ed7d27.zip
SD-256 enable colored output by default on unix
`scala.color` now has 3 states: `true`, `false` and `auto` (the default). `auto` allows colors if not on windows and if the shell is interactive (as in, both stdin and stdout are a tty). The autodetect works as expected when run via SBT too, and it can always be overriden on the CLI or via JAVA_OPTS.
Diffstat (limited to 'src/library/scala/util/Properties.scala')
-rw-r--r--src/library/scala/util/Properties.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index 7b21351cf6..29a635fcbe 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -154,6 +154,12 @@ private[scala] trait PropertiesTrait {
/* Some runtime values. */
private[scala] def isAvian = javaVmName contains "Avian"
+ private[scala] def coloredOutputEnabled: Boolean = propOrElse("scala.color", "auto") match {
+ case "auto" => System.console() != null && !isWin
+ case a if a.toLowerCase() == "true" => true
+ case _ => false
+ }
+
// This is looking for javac, tools.jar, etc.
// Tries JDK_HOME first, then the more common but likely jre JAVA_HOME,
// and finally the system property based javaHome.