Details

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

      Description

      IIRC, the "spirit" of jruby -x is to be like perl -x, and be able to do something like this:

      #!/bin/sh
      exec jruby --1.9 -x $0 "$@"
      #!jruby
      ...
      

      The "-x" parsing code calls findScript, which looks for the first line containing starting with "#Unable to render embedded object: File (" and >2 characters. Unfortunately, this finds the #) not found./bin/sh line. The code should skip the first line (presumably a #! for another interpreter that will exec jruby -x ...). I'm trying to do this so I can have a command line script that's run with jruby 1.9 (and doesn't require the user to set an environment variable or something; other suggestions welcome).

      This is basically how the perl interpreter deals with -x (it actually requires the #! it finds has perl in it somewhere). For example:

      0 petef-xps(~) % ./foo.pl a b c
      a b c
      0 petef-xps(~) % cat foo.pl
      #!/bin/sh
      exec perl -x $0 "$@"
      #!perl
      print join(" ", @ARGV), "\n";
      

        Activity

        Hide
        Hiro Asari added a comment -

        That is a secondary intent. JRuby's intent is to be compatible with how MRI behaves. (I'm sure MRI's intent is to behave as perl does.)

        Can you show us how JRuby's handling of -x differs from how MRI does? Otherwise, this is not a bug.

        Show
        Hiro Asari added a comment - That is a secondary intent. JRuby's intent is to be compatible with how MRI behaves. (I'm sure MRI's intent is to behave as perl does.) Can you show us how JRuby's handling of -x differs from how MRI does? Otherwise, this is not a bug.
        Hide
        Pete Fritchman added a comment -

        ruby MRI works:

        0 carrera(~/tmp) % rvm use ruby-1.8.7
        Using /home/petef/.rvm/gems/ruby-1.8.7-p334
        0 carrera(~/tmp) % cat test.sh
        #!/bin/sh
        echo "in /bin/sh"
        exec ruby -x $0 "$@"
        #!ruby
        puts "in ruby"
        0 carrera(~/tmp) % ./test.sh
        in /bin/sh
        in ruby

        jruby does not:

        0 carrera(~/tmp) % rvm use jruby-1.6.1
        Using /home/petef/.rvm/gems/jruby-1.6.1
        0 carrera(~/tmp) % cat test-jruby.sh
        #!/bin/sh
        exec /home/petef/.rvm/rubies/jruby-1.6.1/bin/jruby -x $0 "$@"
        #!ruby
        puts "hi"
        0 carrera(~/tmp) % ./test-jruby.sh
        SyntaxError: ./test-jruby.sh:2: ptfunknown regexp options - ptf

        Show
        Pete Fritchman added a comment - ruby MRI works: 0 carrera(~/tmp) % rvm use ruby-1.8.7 Using /home/petef/.rvm/gems/ruby-1.8.7-p334 0 carrera(~/tmp) % cat test.sh #!/bin/sh echo "in /bin/sh" exec ruby -x $0 "$@" #!ruby puts "in ruby" 0 carrera(~/tmp) % ./test.sh in /bin/sh in ruby jruby does not: 0 carrera(~/tmp) % rvm use jruby-1.6.1 Using /home/petef/.rvm/gems/jruby-1.6.1 0 carrera(~/tmp) % cat test-jruby.sh #!/bin/sh exec /home/petef/.rvm/rubies/jruby-1.6.1/bin/jruby -x $0 "$@" #!ruby puts "hi" 0 carrera(~/tmp) % ./test-jruby.sh SyntaxError: ./test-jruby.sh:2: ptfunknown regexp options - ptf
        Hide
        Hiro Asari added a comment -

        It appears to be fixed on the master.

        $ cat temp/jruby-5823.sh 
        #!/bin/sh
        echo "in /bin/sh"
        exec /usr/local/jruby/bin/jruby -x $0 "$@"
        #!jruby
        puts RUBY_DESCRIPTION
        puts "in ruby"
        $ ./temp/jruby-5823.sh 
        in /bin/sh
        jruby 1.7.0.dev (ruby-1.8.7-p357) (2012-01-01 de4556e) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
        in ruby
        
        Show
        Hiro Asari added a comment - It appears to be fixed on the master. $ cat temp/jruby-5823.sh #!/bin/sh echo "in /bin/sh" exec /usr/local/jruby/bin/jruby -x $0 "$@" #!jruby puts RUBY_DESCRIPTION puts "in ruby" $ ./temp/jruby-5823.sh in /bin/sh jruby 1.7.0.dev (ruby-1.8.7-p357) (2012-01-01 de4556e) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java] in ruby

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Pete Fritchman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: