diff --git a/lib/reline.rb b/lib/reline.rb index 5d1fcbf8e8..3995bae3da 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -114,7 +114,11 @@ def filename_quote_characters=(v) end def special_prefixes=(v) - @special_prefixes = v.encode(encoding) + if v.nil? + @special_prefixes = '' + else + @special_prefixes = v.encode(encoding) + end end def completion_case_fold=(v) @@ -174,14 +178,26 @@ def dialog_proc(name_sym) end def input=(val) - raise TypeError unless val.respond_to?(:getc) or val.nil? + raise TypeError unless val.respond_to?(:getc) if val.respond_to?(:getc) && io_gate.respond_to?(:input=) io_gate.input = val + elsif val.nil? + io_gate.input = STDIN + return + else + # noop + # Reline::Windows does not suppport input= method end end def output=(val) - raise TypeError unless val.respond_to?(:write) or val.nil? + if val.nil? + val = STDOUT + return + elsif !val.respond_to?(:write) + raise TypeError + end + @output = val io_gate.output = val end