1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2010-06-05 06:59:12 +00:00
parent 2c2ae5b164
commit af97da84ed
3 changed files with 13 additions and 8 deletions

View file

@ -1,3 +1,9 @@
Sat Jun 5 15:59:08 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <nobu@ruby-lang.org>
* test/ruby/envutil.rb (EnvUtil#invoke_ruby): support for child
@ -22,11 +28,6 @@ Sat Jun 5 10:03:31 2010 Tanaka Akira <akr@fsij.org>
* .gdbinit (rp): detect and show RTypedData.
Sat Jun 5 09:56:57 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <nobu@ruby-lang.org>
* file.c (rb_f_test): 'W' should test writable by real uid/git,

8
ruby.c
View file

@ -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) {

View file

@ -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