jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
JRuby
  • JRuby
  • JRUBY-5823

jruby -x bug

  • Log In
  • Views
    • XML
    • Word
    • Printable

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

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Hiro Asari added a comment - 20/Aug/11 12:19 PM

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 - 20/Aug/11 12:19 PM 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
Permalink
Pete Fritchman added a comment - 30/Aug/11 4:52 PM

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 - 30/Aug/11 4:52 PM 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
Permalink
Hiro Asari added a comment - 02/Jan/12 1:01 AM

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 - 02/Jan/12 1:01 AM 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
Vote (0)
Watch (0)

Dates

  • Created:
    25/May/11 1:53 PM
    Updated:
    02/Jan/12 1:01 AM
    Resolved:
    02/Jan/12 1:01 AM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.