summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-01-20 17:28:56 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-23 13:37:40 +0900
commit588a86e32c9e646823e1436e53ffe1c37206abd3 (patch)
treef0aa70912fb1c9a86d80e624e836680e93ec83a8
parent0ed3384fd463ff80f5e55f7d4c62338fb15337d5 (diff)
Warn non-nil `$,` in `IO#print` too
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2920
-rw-r--r--io.c3
-rw-r--r--test/ruby/test_io.rb2
2 files changed, 4 insertions, 1 deletions
diff --git a/io.c b/io.c
index 19fe51bcf6..b3175df6c0 100644
--- a/io.c
+++ b/io.c
@@ -7615,6 +7615,9 @@ rb_io_print(int argc, const VALUE *argv, VALUE out)
line = rb_lastline_get();
argv = &line;
}
+ if (argc > 1 && !NIL_P(rb_output_fs)) {
+ rb_warn("$, is set to non-nil value");
+ }
for (i=0; i<argc; i++) {
if (!NIL_P(rb_output_fs) && i>0) {
rb_io_write(out, rb_output_fs);
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 6bdc7bb27f..af2b08de95 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2572,7 +2572,7 @@ class TestIO < Test::Unit::TestCase
$\ = "\n"
pipe(proc do |w|
w.print('a')
- w.print('a','b','c')
+ EnvUtil.suppress_warning {w.print('a','b','c')}
w.close
end, proc do |r|
assert_equal("a\n", r.gets)