mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
187de9240a
commit
1ad0d8ecad
1 changed files with 2 additions and 9 deletions
|
|
@ -857,14 +857,6 @@ getpass_call(VALUE io)
|
||||||
return ttymode(io, rb_io_gets, set_noecho, NULL);
|
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
|
static void
|
||||||
prompt(int argc, VALUE *argv, VALUE io)
|
prompt(int argc, VALUE *argv, VALUE io)
|
||||||
{
|
{
|
||||||
|
|
@ -900,7 +892,8 @@ console_getpass(int argc, VALUE *argv, VALUE io)
|
||||||
VALUE str, wio;
|
VALUE str, wio;
|
||||||
|
|
||||||
rb_check_arity(argc, 0, 1);
|
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);
|
prompt(argc, argv, wio);
|
||||||
str = rb_ensure(getpass_call, io, puts_call, wio);
|
str = rb_ensure(getpass_call, io, puts_call, wio);
|
||||||
return str_chomp(str);
|
return str_chomp(str);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue