diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-29 10:12:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-29 10:12:48 +0000 |
commit | 66fe2c0dd9f30efe785ce5f7411d9386fbcfeadc (patch) | |
tree | b8d4477b36f117be59a5c5a14ba505d0437b255b | |
parent | b6b1038c6bc487b0b8f7d1675d02a22a4ee8f4b8 (diff) | |
download | ruby-66fe2c0dd9f30efe785ce5f7411d9386fbcfeadc.tar.gz |
ruby.c: command line option over RUBYOPT env
* ruby.c (proc_options): -W command line option should be able to
override -w in RUBYOPT environment variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ruby.c | 10 | ||||
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 4 |
3 files changed, 17 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Tue Dec 29 19:12:46 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * ruby.c (proc_options): -W command line option should be able to + override -w in RUBYOPT environment variable. + Tue Dec 29 17:54:16 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * eval.c (ignored_block): warn if a block is given to `using`, @@ -110,6 +110,7 @@ struct cmdline_options { } enc; } src, ext, intern; VALUE req_list; + unsigned int warning: 1; }; static void init_ids(struct cmdline_options *); @@ -879,15 +880,19 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt) opt->dump |= DUMP_BIT(version_v); opt->verbose = 1; case 'w': - ruby_verbose = Qtrue; + if (!opt->warning) { + opt->warning = 1; + ruby_verbose = Qtrue; + } s++; goto reswitch; case 'W': - { + if (!opt->warning) { size_t numlen; int v = 2; /* -W as -W2 */ + opt->warning = 1; if (*++s) { v = scan_oct(s, 1, &numlen); if (numlen == 0) @@ -1705,6 +1710,7 @@ load_file_internal(VALUE argp_v) if (RSTRING_PTR(line)[RSTRING_LEN(line) - 2] == '\r') RSTRING_PTR(line)[RSTRING_LEN(line) - 2] = '\0'; if ((p = strstr(p, " -")) != 0) { + opt->warning = 0; moreswitches(p + 1, opt, 0); } diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 72672292b7..95d60d9933 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -258,6 +258,10 @@ class TestRubyOptions < Test::Unit::TestCase assert_equal([], e) end + ENV['RUBYOPT'] = '-w' + assert_in_out_err(%w(), "p $VERBOSE", ["true"]) + assert_in_out_err(%w(-W1), "p $VERBOSE", ["false"]) + assert_in_out_err(%w(-W0), "p $VERBOSE", ["nil"]) ensure if rubyopt_orig ENV['RUBYOPT'] = rubyopt_orig |