From ef92c2a16e77a7a2cd107d7ee72e72942e13e0a1 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 5 Aug 2009 10:19:18 +0000 Subject: * ruby.c (load_file_internal): assumes -x flag if no "ruby" is in the shebang line. [ruby-dev:39015] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 297f0e281..2bfd88c89 100644 --- a/ruby.c +++ b/ruby.c @@ -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: -- cgit