Bug #16647
closedRedefining $/ causes irb to misbehave
Description
If I start irb and then do:
$/ = "asdf"
then every character I type shows a newline on the irb console. Previous versions of ruby do not have this behavior, and it is annoying.
Updated by Eregon (Benoit Daloze) about 4 years ago
Out of curiosity, why do you overwrite $/?
My personal opinion is we should deprecate all these variables affecting default separators,
they tend to break any non-trivial program, not just IRB, and explicit seems always clearer.
Updated by Hanmac (Hans Mackowiak) about 4 years ago
Related to https://bugs.ruby-lang.org/issues/14240
changing these variables is deprecated now, and it shows a warning
Updated by aycabta (aycabta .) about 4 years ago
- Status changed from Open to Closed
It was a problem with Reline. I fixed it by https://github.com/ruby/reline/pull/129.
My personal opinion is we should deprecate all these variables affecting default separators,
they tend to break any non-trivial program, not just IRB, and explicit seems always clearer.
I think so, but...maybe, so many beginners use IRB to check Ruby's features.
It's just my opinion, and it was easy to fix. So I fixed it for beginners.
hanging these variables is deprecated now, and it shows a warning
Yes, @nobu (Nobuyoshi Nakada) said "I forgot it (#14240) to create Pull Request (https://github.com/ruby/ruby/pull/2920) even I created a branch." after I talked about this issue (#16647) to @nobu (Nobuyoshi Nakada).
I'll remove the fix of Reline after the global variables are completely removed.
Updated by mehagar (Michael Hagar) about 4 years ago
Eregon (Benoit Daloze) wrote in #note-1:
Out of curiosity, why do you overwrite $/?
My personal opinion is we should deprecate all these variables affecting default separators,
they tend to break any non-trivial program, not just IRB, and explicit seems always clearer.
I was following along an example from the book "The Well Grounded Rubyist, 3rd edition", that was illustrating how IO objects iterate.