summaryrefslogtreecommitdiff
path: root/.azure-pipelines/rbreadline.diff
blob: c13957761030a539e9c701134e869d4940757118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
diff --git a/rbreadline.rb b/rbreadline.rb
index c710961..e35408c 100644
--- a/rbreadline.rb
+++ b/rbreadline.rb
@@ -16,6 +16,7 @@ end
 
 module RbReadline
   require 'etc'
+  require 'io/console'
 
   RL_LIBRARY_VERSION = "5.2"
   RL_READLINE_VERSION  = 0x0502
@@ -1092,6 +1093,9 @@ module RbReadline
   @current_readline_init_include_level = 0
   @current_readline_init_lineno = 0
 
+  # Used in windows 
+  @is_pipe = false
+
   ENV["HOME"] ||= "#{ENV["HOMEDRIVE"]}#{ENV["HOMEPATH"]}"
   if !File.directory? ENV["HOME"]
     raise RuntimeError.new("HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory")
@@ -4490,6 +4494,10 @@ module RbReadline
     end
 
     def rl_getc(stream)
+	  # below added as test for whether we're connected to a pipe or a keyboard.
+      # Pipe connection is probably running under a test suite.
+      return (stream.getc || EOF rescue EOF) if @is_pipe
+
       while (@kbhit.Call == 0)
         # If there is no input, yield the processor for other threads
         sleep(@_keyboard_input_timeout)
@@ -4740,6 +4748,7 @@ module RbReadline
   def readline_internal_charloop()
     lastc = -1
     eof_found = false
+	@is_pipe = (!@rl_outstream.winsize rescue true)
 
     while (!@rl_done)
       lk = @_rl_last_command_was_kill