Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Suspend not working in IRB Ruby 3.1.2 #466

Closed
sandro opened this issue Sep 7, 2022 · 8 comments · Fixed by #535
Closed

Suspend not working in IRB Ruby 3.1.2 #466

sandro opened this issue Sep 7, 2022 · 8 comments · Fixed by #535

Comments

@sandro
Copy link

sandro commented Sep 7, 2022

Description

When I enter IRB session, I expect pressing CTRL-Z to suspend the program, but it does not. If I press <Enter> after CTRL-Z I see irb(main):002:0* ^Z

Suspend functionality works fine for me on Ruby 2.7 and Ruby 3.0.1

Terminal Emulator

What's your terminal emulator?

ZSH
iTerm2 and Terminal on Mac OS

@junaruga
Copy link
Member

junaruga commented Sep 7, 2022

What's your terminal emulator?

ZSH

I suppose that the "ZSH" is not the terminal emulator but the shell. The terminal emulator is like "terminator", "alacrity", "xterm" and etc. See https://en.wikipedia.org/wiki/List_of_terminal_emulators.

@sandro
Copy link
Author

sandro commented Sep 7, 2022

@junaruga my mistake, I use iTerm2 but Terminal on Mac OS is also affected.

@elfham
Copy link
Contributor

elfham commented Sep 8, 2022

It looks like that bug got in at #335.

@sandro
Copy link
Author

sandro commented Sep 8, 2022

@elfham that was a year ago. Is IRB in Ruby 3.1.2 really that old?

I have the problem with this sample code running against reline master with Ruby 3.1.2:

  require "reline"
  prompt = "> "

  begin
    while true
      text = Reline.readmultiline(prompt) do |data|
        puts "in", data
      end
      puts "you entered"
      puts text
    end
  rescue Interrupt
    puts "CTRL-C"
    exit 0
  end

Using Ctrl-Z works fine when using Ruby 3.0.1

@elfham
Copy link
Contributor

elfham commented Sep 10, 2022

Since this bug was introduced in #335, I believe that subsequent versions of Reline have had the problem.
(Reline 0.2.8~, Ruby 3.1.0~)

As I commented in #321 (comment) , I think commit #335 is inappropriate and should be reverted once.

@sandro
Copy link
Author

sandro commented Sep 10, 2022

@elfham Oh, my mistake, I thought you were saying the bug was fixed in #335 not that it was introduced there. Sorry for the confusion, and thanks for shedding light on this problem!

@casper
Copy link

casper commented Jan 15, 2023

Just installed Ruby 3.2.0 and ran into this same problem (Ubuntu Linux).
Strangely on Ruby 3.0, which also uses Reline, C-z works as expected.

@brasic
Copy link
Contributor

brasic commented Apr 24, 2023

I can confirm that this is still an issue in main for all ruby versions and that it's caused by #335. I use the following awkward monkeypatch in .irbrc to restore the ability to suspend irb with C-z:

module Signal
  @real_trap = method(:trap)
  def self.trap(*args, &block)
    if args[0] != 'TSTP'
      @real_trap.call(*args, &block)
    end
  end
end

I've opened #535 to revert the prior PR, as I don't believe it does anything useful.

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

Successfully merging a pull request may close this issue.

5 participants