Task

Demonstrate how to check whether the output device is a terminal or not.



Related task

   Check input device is a terminal


import org.fusesource.jansi.internal.CLibrary._
 
object IsATty  extends App {
 
  var enabled = true
 
  def apply(enabled: Boolean): Boolean = {
    // We must be on some unix variant..
    try {
      enabled && isatty(STDOUT_FILENO) == 1
    }
    catch {
      case ignore: Throwable =>
        ignore.printStackTrace()
        false
 
    }
  }
 
    println("tty " + apply(true))
}