ruby-changes:64081
From: Jeremy <ko1@a...>
Date: Fri, 11 Dec 2020 03:16:54 +0900 (JST)
Subject: [ruby-changes:64081] dca13e2bf7 (master): Make ruby -We the same as ruby -W -e
https://git.ruby-lang.org/ruby.git/commit/?id=dca13e2bf7 From dca13e2bf7b7efeb2841a039e3cfd7b5cd650a7b Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Tue, 8 Dec 2020 09:00:04 -0800 Subject: Make ruby -We the same as ruby -W -e This changes the behavior, which I'm not sure is acceptable. However, it's odd to allow an option to be combined, but change the behavior of the option when combined. diff --git a/ruby.c b/ruby.c index ebea8cc..fc9adf7 100644 --- a/ruby.c +++ b/ruby.c @@ -1140,7 +1140,7 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1140 if (*++s) { v = scan_oct(s, 1, &numlen); if (numlen == 0) - v = 1; + v = 2; s += numlen; } if (!opt->warning) { diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index be08ec6..7b1df5b 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -72,8 +72,9 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L72 ENV['RUBYOPT'] = nil assert_in_out_err(%w(-W0 -e) + ['p $-W'], "", %w(0), []) assert_in_out_err(%w(-W1 -e) + ['p $-W'], "", %w(1), []) - assert_in_out_err(%w(-Wx -e) + ['p $-W'], "", %w(1), []) + assert_in_out_err(%w(-Wx -e) + ['p $-W'], "", %w(2), []) assert_in_out_err(%w(-W -e) + ['p $-W'], "", %w(2), []) + assert_in_out_err(%w(-We) + ['p $-W'], "", %w(2), []) assert_in_out_err(%w(-w -W0 -e) + ['p $-W'], "", %w(0), []) assert_in_out_err(%w(-W:deprecated -e) + ['p Warning[:deprecated]'], "", %w(true), []) assert_in_out_err(%w(-W:no-deprecated -e) + ['p Warning[:deprecated]'], "", %w(false), []) @@ -82,6 +83,7 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L83 assert_in_out_err(%w(-W:qux), "", [], /unknown warning category: `qux'/) assert_in_out_err(%w(-w -e) + ['p Warning[:deprecated]'], "", %w(true), []) assert_in_out_err(%w(-W -e) + ['p Warning[:deprecated]'], "", %w(true), []) + assert_in_out_err(%w(-We) + ['p Warning[:deprecated]'], "", %w(true), []) assert_in_out_err(%w(-e) + ['p Warning[:deprecated]'], "", %w(false), []) ensure ENV['RUBYOPT'] = save_rubyopt -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/