Skip to content
Snippets Groups Projects
Commit 3e2f8510 authored by Adam Leff's avatar Adam Leff
Browse files

Fix NilClass error when stdin is not a terminal


In some cases, such as when running tests under minitest, stdin
can get remapped in such a way that shell-outs to commands like
`stty -a` will report "stdin is not a terminal". This can cause
the elements in @_rl_tty_chars to be nil.

In #prepare_terminal_settings, rl_bind_key is called for function
:rl_restart_output, but if @_rl_tty_chars.t_start is nil,
StringScanner.new(seq) in rl_translate_keyseq will throw:

```
Error: no implicit conversion of nil into String
```

This appears to be the only case in the codebase where an unguarded
call to rl_bind_key exists, so this change ensures that we do not
try and map a nil key to :rl_restart_output.

Signed-off-by: default avatarAdam Leff <adam@leff.co>
parent 68457ded
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -7016,7 +7016,7 @@ module RbReadline
 
setting << " -ixoff"
 
rl_bind_key(@_rl_tty_chars.t_start, :rl_restart_output)
rl_bind_key(@_rl_tty_chars.t_start, :rl_restart_output) unless @_rl_tty_chars.t_start.nil?
@_rl_eof_char = @_rl_tty_chars.t_eof
 
#setting << " -isig"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment