Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Set default value for Reline.input, Reline.output and Reline.special_prefixes #805

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ima1zumi
Copy link
Member

Close #774

I have changed that default values are assigned to Reline.input=, Reline.output=, and Reline.special_prefixes= when nil is passed to these methods. This change aligns the behavior of Reline with that of readline-ext.

readline-ext sets special_prefixes=nil to nil, but I think the method name suggests that a string is expected. Reline.special_prefixes has been modified to default to an empty string instead of nil.

❯ ASDF_RUBY_VERSION=2.6.10 irb
irb(main):001> Readline.special_prefixes = nil
nil
irb(main):002> Readline.special_prefixes
nil

readline-ext

https://github.com/ruby/readline-ext/blob/9ee1b1a2f848ebb98b8ea07969a100dd24548411/ext/readline/readline.c#L561-L629

https://github.com/ruby/readline-ext/blob/9ee1b1a2f848ebb98b8ea07969a100dd24548411/ext/readline/readline.c#L1463-L1494

if val.respond_to?(:getc) && io_gate.respond_to?(:input=)
io_gate.input = val
if val.nil?
io_gate.input = STDIN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reline::Windows have attr_writer :output but does not have input= method and it does not support changing input.

We need a check like before, or add a no-op input= method to Reline::Windows.

if val.nil?
@output = STDOUT
io_gate.output = STDOUT
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just val = STDOUT is enough and simple.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Nil config items cause execeptions by not causing use of default values
2 participants