Actions
Bug #12712
closedIRB won't work after input `%q_abc\_def\_ghi_`
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
Description
After inputting %q_abc\_def\_ghi_
in IRB, I get no response and have to stop with Ctrl-C. Here is the example:
➜ ~ irb
irb(main):001:0> %q_abc\_def\_ghi_
irb(main):002:1> 123
irb(main):003:1> exit
irb(main):004:1>
irb(main):005:1*
irb(main):006:1* ^C
But %q_abc\_aaa\_ghi_
returns the value immediately:
➜ ~ irb
irb(main):001:0> %q_abc\_aaa\_ghi_
=> "abc_aaa_ghi"
irb(main):002:0>
%Q_abc\_def\_ghi_
is also okay:
➜ ~ irb
irb(main):001:0> %Q_abc\_def\_ghi_
=> "abc_def_ghi"
irb(main):002:0>
%q_abc\_def_
is also okay:
➜ ~ irb
irb(main):001:0> %q_abc\_def_
=> "abc_def"
irb(main):002:0>
It seems IRB can't handle def
string in the middle of %q notation properly. You can read some discussions here:
http://stackoverflow.com/questions/39197026/escaping-in-q-notation-wont-work-in-irb
And when I create a .rb file and run it with ruby
command, it can escape \_def
properly:
# test.rb
puts %q_abc\_def\_ghi_
➜ ~ ruby test.rb
abc_def_ghi
➜ ~
So I think the right behavior should be like this:
➜ ~ irb
irb(main):001:0> %q_abc\_def\_ghi_
=> "abc_def_ghi"
Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago
- Status changed from Open to Closed
This appears to have been fixed between 2.6 and 2.7.0-preview1:
$ irb26
irb(main):001:0> %q_abc\_def\_ghi_
irb(main):002:1> ^C
irb(main):002:0>
$ irb27
irb(main):001:0> %q_abc\_def\_ghi_
=> "abc_def_ghi"
irb(main):002:0>
Actions
Like0
Like0