diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-05 06:59:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-05 06:59:12 +0000 |
commit | af97da84edac2ccbacc9b10661002b1ddf86e7f8 (patch) | |
tree | b624c7084fe708aa5443ebdad5ad70ce861b52ba /ruby.c | |
parent | 2c2ae5b16450db3597815d190c557e82c10104d6 (diff) |
* ruby.c (process_options, load_file_internal): $0 seen from
required libraries by -r option should be the main script.
[ruby-core:23717]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1356,8 +1356,6 @@ process_options(int argc, char **argv, struct cmdline_options *opt) } } ruby_init_gems(!(opt->disable & DISABLE_BIT(gems))); - rb_progname = opt->script_name; - rb_vm_set_progname(rb_progname); ruby_set_argv(argc, argv); process_sflag(&opt->sflag); @@ -1379,6 +1377,7 @@ process_options(int argc, char **argv, struct cmdline_options *opt) } while (0) if (opt->e_script) { + VALUE progname = rb_progname; rb_encoding *eenc; if (opt->src.enc.index >= 0) { eenc = rb_enc_from_index(opt->src.enc.index); @@ -1387,7 +1386,9 @@ process_options(int argc, char **argv, struct cmdline_options *opt) eenc = lenc; } rb_enc_associate(opt->e_script, eenc); + rb_vm_set_progname(rb_progname = opt->script_name); require_libraries(&opt->req_list); + rb_vm_set_progname(rb_progname = progname); PREPARE_PARSE_MAIN({ tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1); @@ -1402,6 +1403,8 @@ process_options(int argc, char **argv, struct cmdline_options *opt) tree = load_file(parser, opt->script, 1, opt); }); } + rb_progname = opt->script_name; + rb_vm_set_progname(rb_progname); if (opt->dump & DUMP_BIT(yydebug)) return Qtrue; if (opt->ext.enc.index >= 0) { @@ -1593,6 +1596,7 @@ load_file_internal(VALUE arg) else if (!NIL_P(c)) { rb_io_ungetbyte(f, c); } + rb_vm_set_progname(rb_progname = opt->script_name); require_libraries(&opt->req_list); /* Why here? unnatural */ } if (opt->src.enc.index >= 0) { |