Bug #1695: String interpolation Issue with escape characters inside an in-string evaluated statement http://redmine.ruby-lang.org/issues/show/1695 Author: Jason Pearlman Status: Open, Priority: Normal Category: core ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [x86_64-linux] Apologies if this has already been addressed but I could not find anything: # Alone, works fine >> 'a'.gsub("'",'\\\'') => "a" # Inside a string in #{} - bombs >> "hi #{'a'.gsub("'",'\\\'')}" [just waits for another "] " SyntaxError: compile error (irb):20: unterminated string meets end of file from (irb):20
[Bug #1695] String interpolation Issue with escape characters inside an in-string evaluated statemen
on 2009-06-26 17:25
on 2009-06-26 17:34
> # Inside a string in #{} - bombs >>> "hi #{'a'.gsub("'",'\\\'')}" > [just waits for another "] > " > SyntaxError: compile error > (irb):20: unterminated string meets end of file > from (irb):20 Looks like a bug in irb's internal "am I done with a complete expression" parser, since it works if within a .rb script. =r
[Bug #1695] String interpolation Issue with escape characters inside an in-string evaluated statemen
on 2009-06-26 17:55
Issue #1695 has been updated by Run Paint Run Run.
Is the problem not simply the use of <"> inside the #gsub?
Ruby expects delimiters to be matched. Your second double quotation mark
terminates the String you began with the first; so the single quotation
mark that immediately follows that is assumed to begin a new string.
IOW, Ruby regards <"hi #{'a'.gsub("> as your first string, which is
followed by <'",'>, which is followed by <\\\'')}">. Hence the syntax
error.
If you want to do all of that on the same line, why not use alternative
delimiters? For example:
%!hi #{'a'.gsub("'",'\\\'')}! #=> "hi a"
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1695
[Bug #1695] String interpolation Issue with escape characters inside an in-string evaluated statemen
on 2009-06-26 18:17
Issue #1695 has been updated by Jason Pearlman. Thanks! If anything this seems more on the IRB side of things. ---------------------------------------- http://redmine.ruby-lang.org/issues/show/1695
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.