diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-05 10:19:18 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-08-05 10:19:18 +0000 |
commit | 8bc6c715475aae33d292b077003d15ea47b9913f (patch) | |
tree | a1f0a4816ac2d9ae47091ef743ba2acf4b9d14d1 /ruby.c | |
parent | cb9038cbafd42efd669524417ee73919bed58c49 (diff) | |
download | ruby-8bc6c715475aae33d292b077003d15ea47b9913f.tar.gz |
* ruby.c (load_file_internal): assumes -x flag if no "ruby" is in
the shebang line. [ruby-dev:39015]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 34 |
1 files changed, 3 insertions, 31 deletions
@@ -1508,6 +1508,7 @@ load_file_internal(VALUE arg) rb_funcall(f, set_encoding, 1, rb_enc_from_encoding(enc)); if (opt->xflag) { + search_shebang: forbid_setid("-x"); opt->xflag = Qfalse; while (!NIL_P(line = rb_io_gets(f))) { @@ -1532,37 +1533,8 @@ load_file_internal(VALUE arg) return 0; if ((p = strstr(RSTRING_PTR(line), "ruby")) == 0) { - void rb_thread_stop_timer_thread(void); - /* not ruby script, kick the program */ - char **argv; - char *path; - char *pend = RSTRING_PTR(line) + RSTRING_LEN(line); - - p = RSTRING_PTR(line); /* 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 *, origarg.argc + 3); - argv[1] = p; - MEMCPY(argv + 2, origarg.argv + 1, char *, origarg.argc); - } - else { - argv = origarg.argv; - } - argv[0] = path; - rb_thread_stop_timer_thread(); - execv(path, argv); - - rb_fatal("Can't exec %s", path); + /* not ruby script, assume -x flag */ + goto search_shebang; } start_read: |