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

Warn non-nil $, in IO#print too

This commit is contained in:
Nobuyoshi Nakada 2020-01-20 17:28:56 +09:00
parent 0ed3384fd4
commit 588a86e32c
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
Notes: git 2020-02-23 16:49:04 +09:00
2 changed files with 4 additions and 1 deletions

3
io.c
View file

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

View file

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