Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8359861

System.console() is non-null even when not a TTY on WSL

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 24.0.1
    • core-libs
    • None

      A JRuby user reported that we are outputting ANSI escape sequences even when piping output to a non-TTY process like "less" or "more". The logic in JRuby determines TTYness by checking the value of java.lang.System.console(), which should be null when stdin and stdout are not both attached to a TTY. However when running in the Windows Subsystem for Linux (WSL), it appears that this is not the case; java.lang.System.console() returns a non-null ProxyingConsole instance even when output is being piped to a non-TTY process.

      This most likely affects any other projects that uses java.lang.System.console() to detect a TTY, such as to provide color or bold text output.

            naoto Naoto Sato
            headius Charles Nutter
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: