ruby-changes:64755
From: Nobuyoshi <ko1@a...>
Date: Tue, 5 Jan 2021 21:47:40 +0900 (JST)
Subject: [ruby-changes:64755] ead8d89bd7 (master): [ruby/io-console] Ignore chomp! result and return the modified string
https://git.ruby-lang.org/ruby.git/commit/?id=ead8d89bd7 From ead8d89bd7fa11601c7d6678a2b9182b01263077 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 5 Jan 2021 13:52:18 +0900 Subject: [ruby/io-console] Ignore chomp! result and return the modified string https://github.com/ruby/io-console/commit/09e5ccc729 diff --git a/ext/io/console/console.c b/ext/io/console/console.c index 1fb1609..e034079 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -1562,7 +1562,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L1562 str_chomp(VALUE str) { if (!NIL_P(str)) { - str = rb_funcallv(str, rb_intern("chomp!"), 0, 0); + rb_funcallv(str, rb_intern("chomp!"), 0, 0); } return str; } diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 3962de3..bec10c5 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -235,6 +235,15 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L235 assert_equal("\r\n", r.gets) assert_equal("\"asdf\"", r.gets.chomp) end + + run_pty("p IO.console.getpass('> ')") do |r, w| + assert_equal("> ", r.readpartial(10)) + sleep 0.1 + w.print "asdf\C-D\C-D" + sleep 0.1 + assert_equal("\r\n", r.gets) + assert_equal("\"asdf\"", r.gets.chomp) + end end def test_iflush -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/