Issue #12712 has been updated by jeremyevans0 (Jeremy Evans).

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>
```

----------------------------------------
Bug #12712: IRB won't work after input `%q_abc\_def\_ghi_`
https://bugs.ruby-lang.org/issues/12712#change-78861

* Author: jnchito (Junichi Ito)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
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"
~~~




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>