From 1ad0d8ecad01eb4d8fface25db59db16929974a4 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 6 Dec 2015 06:30:11 +0000 Subject: console.c: prompt to stderr * ext/io/console/console.c (console_getpass): print prompt to stderr when reading from stdin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/io/console/console.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'ext/io') diff --git a/ext/io/console/console.c b/ext/io/console/console.c index 629a7fbd6d..50a2975bf8 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -857,14 +857,6 @@ getpass_call(VALUE io) return ttymode(io, rb_io_gets, set_noecho, NULL); } -static VALUE -write_io(VALUE io) -{ - VALUE wio = rb_io_get_write_io(io); - if (wio == io && io == rb_stdin) wio = rb_stdout; - return wio; -} - static void prompt(int argc, VALUE *argv, VALUE io) { @@ -900,7 +892,8 @@ console_getpass(int argc, VALUE *argv, VALUE io) VALUE str, wio; rb_check_arity(argc, 0, 1); - wio = write_io(io); + wio = rb_io_get_write_io(io); + if (wio == io && io == rb_stdin) wio = rb_stderr; prompt(argc, argv, wio); str = rb_ensure(getpass_call, io, puts_call, wio); return str_chomp(str); -- cgit v1.2.3