Project

General

Profile

Bug #13270

IRB hangs when printing "\e]"

Added by domaio (Dorian M) 4 months ago. Updated 4 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
[ruby-core:79878]

Description

Steps to reproduce:

  • irb
  • print "\e]"
  • Or: puts "\e["
  • try CMD+C, nothing happens
  • try CMD+D, prints "30m"

Expected behavior:

  • just prints "30m" (that's what pry does)

Ruby versions tried:

  • ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
  • ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

History

#1 [ruby-core:79879] Updated by shevegen (Robert A. Heiler) 4 months ago

Is this darwin-specific? It appears to work fine on my linux system here.

ruby 2.4.0p0 (2016-12-24 revision 57164) [i686-linux]

#2 [ruby-core:79883] Updated by nobu (Nobuyoshi Nakada) 4 months ago

  • Status changed from Open to Feedback

I can't reproduce it on darwin15.

Does it happen without irb, just ruby -e print "\e]"?
If only with irb, does it with irb -f?

#3 [ruby-core:79896] Updated by snood1205 (Eli Sadoff) 4 months ago

  • Status changed from Feedback to Open

I can reproduce it on Darwin, so I'm switching it back to open.

My ruby -v is ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin14]

Also it occurs with irb -f but not with ruby -e

#4 [ruby-core:79898] Updated by snood1205 (Eli Sadoff) 4 months ago

Even more information, this is reproducible on ruby -v ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux], but instead of printing out "30m" after CMD+D it prints out nothing. This seems to be a bug within IRB. Interesting, this behavior seems to be OS defined as well. The following program in C

#include <stdio.h>

int main()
{
        puts("\e]");
}

has different outputs based on the OS. On macOS Sierra, it outputs 30m with gcc, cc, and clang, whereas on Fedora 22 it outputs nothing with both gcc and cc. I can't exactly figure out what is wrong, but it is quite odd.

#5 [ruby-core:79902] Updated by nobu (Nobuyoshi Nakada) 4 months ago

  • Status changed from Open to Feedback

What terminal emulator are you using, the standard Terminal.app?

#6 [ruby-core:79912] Updated by domaio (Dorian M) 4 months ago

Nobuyoshi Nakada wrote:

What terminal emulator are you using, the standard Terminal.app?

I'm using iTerm 3.0.14.

And on Terminal.app (v2.7.1 (387)) I get

>> puts "\e]"

il
>> puts "\e["

nil

(notice the first "n" missing)

Also, why pry (0.10.4), on iTerm:

> puts "\e["

nil
> puts "\e]"
1;36mnil
>

I'm on MacOS Sierra 10.12.1 (16B2555)

#7 [ruby-core:79937] Updated by znz (Kazuhiro NISHIYAMA) 4 months ago

I can reproduce print "\e]" and Ctrl+C, nothing happens. But I can't reproduce using puts "\e[". And I can't reproduce Ctrl+D prints "30m". Ctrl+D causes simply exited.

I think iTerm eats output from "\e]" (OSC) to "\a" (BEL) (or "\e" or something else).

pry outputs some "\e"s after evaluation, then it seems to be without hang.

I typed print "\e]", Enter, Ctrl+C, puts "\a" (can't see), Enter. Then it outputs => nil and prompt.

% rbenv exec irb -r irb/completion --simple-prompt
>> print "\e]"

=> nil
>>

#8 [ruby-core:79956] Updated by nobu (Nobuyoshi Nakada) 4 months ago

  • Status changed from Feedback to Rejected

It is not ruby specific, and (probably) expected behavior of some terminal emulators.

Also available in: Atom PDF