From 0e4121aa5ba9875f3b2d3b130cc4f63a1f50fc26 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 14 Oct 2009 04:24:16 +0000 Subject: [PATCH] * ruby.c (process_options): script name should not be shown in an error message before loaded. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ruby.c | 4 ++-- test/ruby/test_rubyoptions.rb | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b5a068df3..fc56787c32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 14 13:24:14 2009 Nobuyoshi Nakada + + * ruby.c (process_options): script name should not be shown in an + error message before loaded. + Wed Oct 14 09:06:38 2009 Nobuyoshi Nakada * eval.c (ruby_run_node): need to call ruby_cleaup() always even diff --git a/ruby.c b/ruby.c index 28bcf31691..4f2f7d4b5a 100644 --- a/ruby.c +++ b/ruby.c @@ -1341,8 +1341,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); @@ -1387,6 +1385,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) { diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 87d2200ad2..4e78b4c827 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -311,4 +311,13 @@ class TestRubyOptions < Test::Unit::TestCase ensure t.close(true) if t end + + def test_notfound + notexist = "./notexist.rb" + rubybin = Regexp.quote(EnvUtil.rubybin) + pat = /\A#{rubybin}:.* -- #{Regexp.quote(notexist)} \(LoadError\)\Z/ + assert_equal(false, File.exist?(notexist)) + assert_in_out_err(["-r", notexist, "-ep"], [], [], pat) + assert_in_out_err([notexist], [], [], pat) + end end