Skip to content

Commit 09e5ccc

Browse files
committed
Ignore chomp! result and return the modified string
1 parent 7c2744e commit 09e5ccc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ext/io/console/console.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ static VALUE
15621562
str_chomp(VALUE str)
15631563
{
15641564
if (!NIL_P(str)) {
1565-
str = rb_funcallv(str, rb_intern("chomp!"), 0, 0);
1565+
rb_funcallv(str, rb_intern("chomp!"), 0, 0);
15661566
}
15671567
return str;
15681568
}

test/io/console/test_io_console.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ def test_getpass
235235
assert_equal("\r\n", r.gets)
236236
assert_equal("\"asdf\"", r.gets.chomp)
237237
end
238+
239+
run_pty("p IO.console.getpass('> ')") do |r, w|
240+
assert_equal("> ", r.readpartial(10))
241+
sleep 0.1
242+
w.print "asdf\C-D\C-D"
243+
sleep 0.1
244+
assert_equal("\r\n", r.gets)
245+
assert_equal("\"asdf\"", r.gets.chomp)
246+
end
238247
end
239248

240249
def test_iflush

0 commit comments

Comments
 (0)