From af97da84edac2ccbacc9b10661002b1ddf86e7f8 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 5 Jun 2010 06:59:12 +0000 Subject: * 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 --- ChangeLog | 11 ++++++----- ruby.c | 8 ++++++-- test/ruby/test_rubyoptions.rb | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b409f35fc6..a979125e91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jun 5 15:59:08 2010 Nobuyoshi Nakada + + * ruby.c (process_options, load_file_internal): $0 seen from + required libraries by -r option should be the main script. + [ruby-core:23717] + Sat Jun 5 15:15:52 2010 Nobuyoshi Nakada * test/ruby/envutil.rb (EnvUtil#invoke_ruby): support for child @@ -22,11 +28,6 @@ Sat Jun 5 10:03:31 2010 Tanaka Akira * .gdbinit (rp): detect and show RTypedData. -Sat Jun 5 09:56:57 2010 Nobuyoshi Nakada - - * ruby.c (process_options): revert r25330, so that $0 can be seen - from required libraries by -r option. [ruby-core:23717] - Sat Jun 5 08:30:42 2010 Nobuyoshi Nakada * file.c (rb_f_test): 'W' should test writable by real uid/git, diff --git a/ruby.c b/ruby.c index 82857c87ba..daaf0d6923 100644 --- a/ruby.c +++ b/ruby.c @@ -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) { diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index dcdfd85fea..03cea47ea9 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -323,7 +323,7 @@ class TestRubyOptions < Test::Unit::TestCase bug1573 = '[ruby-core:23717]' assert_equal(false, File.exist?(notexist)) assert_in_out_err(["-r", notexist, "-ep"], "", [], /\A-e:.* -- #{pat} \(LoadError\)\Z/, bug1573) - assert_in_out_err([notexist], "", [], /\A#{pat}:.* -- #{pat} \(LoadError\)\Z/, bug1573) + assert_in_out_err([notexist], "", [], /\A#{rubybin}:.* -- #{pat} \(LoadError\)\Z/, bug1573) end def test_program_name -- cgit v1.2.3