JRuby does not support options in shebang line
----------------------------------------------
Key: JRUBY-2901
URL: http://jira.codehaus.org/browse/JRUBY-2901
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1.3
Reporter: Koichiro Ohba
Attachments: shebang-option-rev7395.patch
This is what I told Tom at Akasaka.rb(FUGU) meeting.
CRuby supports ruby options in shebang line, which appears at the head of
scripts.
However, JRuby dosen't support this.
There is a difference between JRuby and CRuby in a sample here.
{code}
# /usr/bin/ruby -d
puts $DEBUG
{code}
{code}
>ruby debug.rb
true
>jruby debug.rb
false
{code}
What makes this difference is that CRuby reads shebang line in a special way.
It uses options in shebang line as command line options.
The function doing this work is here.
ruby.c at 833 line (1.8.6):
{code}
static void
load_file(fname, script)
const char *fname;
int script;
{
...
c = rb_io_getc(f);
if (c == INT2FIX('#')) {
line = rb_io_gets(f);
if (NIL_P(line)) return;
line_start++;
if (RSTRING(line)->len > 2 && RSTRING(line)->ptr[0] == '!') {
if ((p = strstr(RSTRING(line)->ptr, "ruby")) == 0) {
/* not ruby script, kick the program */
char **argv;
char *path;
char *pend = RSTRING(line)->ptr + RSTRING(line)->len;
p = RSTRING(line)->ptr + 1; /* skip `#!' */
if (pend[-1] == '\n') pend--; /* chomp line */
if (pend[-1] == '\r') pend--;
*pend = '\0';
while (p < pend && ISSPACE(*p))
p++;
path = p; /* interpreter path */
while (p < pend && !ISSPACE(*p))
p++;
*p++ = '\0';
if (p < pend) {
argv = ALLOCA_N(char*, origargc+3);
argv[1] = p;
MEMCPY(argv+2, origargv+1, char*, origargc);
}
else {
argv = origargv;
}
argv[0] = path;
execv(path, argv);
ruby_sourcefile = rb_source_filename(fname);
ruby_sourceline = 1;
rb_fatal("Can't exec %s", path);
}
{code}
I've created a patch adding this support just for a reference.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email