Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      jruby-1.6.7 :001 > '2300' =~ /\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\z/
       => 0
      
      jruby-1.7.0.dev :001 > '2300' =~ /A(([0-1][0-9])|([2][0-3]))[0-5][0-9]z/
       => nil
      

        Activity

        Hide
        Hiro Asari added a comment -

        Looks like the backslash is getting gobbled.

        irb(main):001:0> '2300' =~ /\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\z/
        '2300' =~ /A(([0-1][0-9])|([2][0-3]))[0-5][0-9]z/
        => nil
        irb(main):002:0> '2300' =~ /\\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\\z/
        '2300' =~ /\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\z/
        => 0
        
        Show
        Hiro Asari added a comment - Looks like the backslash is getting gobbled. irb(main):001:0> '2300' =~ /\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\z/ '2300' =~ /A(([0-1][0-9])|([2][0-3]))[0-5][0-9]z/ => nil irb(main):002:0> '2300' =~ /\\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\\z/ '2300' =~ /\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\z/ => 0
        Hide
        Thomas E Enebo added a comment -
        jruby -e 'p("2300" =~ /\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\z/)'
        0
        

        Say what? irb thing w/ eval?

        Show
        Thomas E Enebo added a comment - jruby -e 'p("2300" =~ /\A(([0-1][0-9])|([2][0-3]))[0-5][0-9]\z/)' 0 Say what? irb thing w/ eval?
        Hide
        Hiro Asari added a comment -

        As suspected, this was introduced by the upgrade to jline:

        a00e2780893646b88dad049f2bb44f09a2119d2c is the first bad commit
        commit a00e2780893646b88dad049f2bb44f09a2119d2c
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Wed Apr 4 15:45:13 2012 -0500
        
            Update to jline2.
        
        :040000 040000 24983efd0e23289d14ad757fc14905b287893b1a 32895ef0f0670be0756066a0df44b2999641e423 M      build_lib
        :100644 100644 01439feeb663e49a8ef7c4ee227b9f468966168c 43d5601a63c22891f3251c98c218a529a7c03b6b M      default.build.properties
        :040000 040000 92f2dd00ba7c9e1cf63d825c1bc61955a79623ac 3473a45a38ffd76c193ae341f2df3f190533a793 M      maven
        :100644 100644 28333f725c6f907676d75b4447317108f7cd3448 85d4c875a162a46be98eb7de820f16ef2dfa8db7 M      shared.iml
        :040000 040000 1a0e10bfa96935033cfce0ff03fda09e78ece453 1ccd343546071255056f89621f4a0d35f2cd41c9 M      src
        
        Show
        Hiro Asari added a comment - As suspected, this was introduced by the upgrade to jline: a00e2780893646b88dad049f2bb44f09a2119d2c is the first bad commit commit a00e2780893646b88dad049f2bb44f09a2119d2c Author: Charles Oliver Nutter <headius@headius.com> Date: Wed Apr 4 15:45:13 2012 -0500 Update to jline2. :040000 040000 24983efd0e23289d14ad757fc14905b287893b1a 32895ef0f0670be0756066a0df44b2999641e423 M build_lib :100644 100644 01439feeb663e49a8ef7c4ee227b9f468966168c 43d5601a63c22891f3251c98c218a529a7c03b6b M default.build.properties :040000 040000 92f2dd00ba7c9e1cf63d825c1bc61955a79623ac 3473a45a38ffd76c193ae341f2df3f190533a793 M maven :100644 100644 28333f725c6f907676d75b4447317108f7cd3448 85d4c875a162a46be98eb7de820f16ef2dfa8db7 M shared.iml :040000 040000 1a0e10bfa96935033cfce0ff03fda09e78ece453 1ccd343546071255056f89621f4a0d35f2cd41c9 M src
        Hide
        Hiro Asari added a comment -

        OK, so I tracked this down to jline2.

        See https://github.com/jline/jline2/blob/e2ab0761802e549d7a39db08ef1c6c940a959400/src/main/java/jline/console/ConsoleReader.java#L513

        In IRB, when the user sends a return key, the finishBuffer() method is invoked. In turn, expandEvents(String) is triggered, along with the content of the buffer. In essence, jline2 is trying to expand \A into a readline event, and basically failing. https://github.com/jline/jline2/blob/e2ab0761802e549d7a39db08ef1c6c940a959400/src/main/java/jline/console/ConsoleReader.java#L546-555

        Is it feasible to disable event expansion for our use?

        diff --git a/src/org/jruby/ext/Readline.java b/src/org/jruby/ext/Readline.java
        index 4b62766..ab2fa0c 100644
        --- a/src/org/jruby/ext/Readline.java
        +++ b/src/org/jruby/ext/Readline.java
        @@ -161,6 +161,7 @@ public class Readline {
                 if (holder.readline == null) {
                     initReadline(runtime, holder); // not overridden, let's go
                 }
        +        holder.readline.setExpandEvents(false);
                 
                 IRubyObject line = runtime.getNil();
                 String v = null;
        
        Show
        Hiro Asari added a comment - OK, so I tracked this down to jline2. See https://github.com/jline/jline2/blob/e2ab0761802e549d7a39db08ef1c6c940a959400/src/main/java/jline/console/ConsoleReader.java#L513 In IRB, when the user sends a return key, the finishBuffer() method is invoked. In turn, expandEvents(String) is triggered, along with the content of the buffer. In essence, jline2 is trying to expand \A into a readline event, and basically failing. https://github.com/jline/jline2/blob/e2ab0761802e549d7a39db08ef1c6c940a959400/src/main/java/jline/console/ConsoleReader.java#L546-555 Is it feasible to disable event expansion for our use? diff --git a/src/org/jruby/ext/Readline.java b/src/org/jruby/ext/Readline.java index 4b62766..ab2fa0c 100644 --- a/src/org/jruby/ext/Readline.java +++ b/src/org/jruby/ext/Readline.java @@ -161,6 +161,7 @@ public class Readline { if (holder.readline == null) { initReadline(runtime, holder); // not overridden, let's go } + holder.readline.setExpandEvents(false); IRubyObject line = runtime.getNil(); String v = null;
        Hide
        Hiro Asari added a comment -

        I committed the above change to the master: 4e6078d.

        If it triggers other problems, we will deal with it later.

        It seems to me, though, if there is a problem, we will have to teach jline2 how to parse Ruby code, which would be a huge job.

        Show
        Hiro Asari added a comment - I committed the above change to the master: 4e6078d. If it triggers other problems, we will deal with it later. It seems to me, though, if there is a problem, we will have to teach jline2 how to parse Ruby code, which would be a huge job.

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Kenneth Lin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: