diff --git a/lib/reline/io.rb b/lib/reline/io.rb index 6a69f91b36..5ea894c2dd 100644 --- a/lib/reline/io.rb +++ b/lib/reline/io.rb @@ -10,15 +10,21 @@ def self.decide_io_gate require 'reline/io/ansi' case RbConfig::CONFIG['host_os'] - when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ + when /mswin|mingw|bccwin|wince|emc/ require 'reline/io/windows' io = Reline::Windows.new if io.msys_tty? || !STDIN.tty? + # In either case stdin is not a console (a Cygwin/MSYS pty pipe such + # as mintty, or a redirect), so the Win32 console input API cannot + # read it. Reline::ANSI.new else io end else + # Ruby built with the msys/cygwin runtime also reaches here. Its tty layer + # speaks ANSI in any terminal (mintty pty or Windows console), so the + # Win32 console API must not be used. https://github.com/ruby/reline/issues/903 Reline::ANSI.new end end