JEG2 / highline

A higher level command-line oriented interface.
Other
1.29k stars 137 forks source link

echo=false or echo='*' requires extra character after enter on Windows #244

Closed galinkinlin closed 1 year ago

galinkinlin commented 5 years ago
highline = 2.0.2
ruby = ruby 2.5.5p157
Windows 10

Hey there!


ask('Enter Password:') do |x|
  x.echo = false
 # or x.echo = '*'
end 

The above script requires an extra character to be entered in the command line after enter is hit on windows before it releases back to the rest of the script (I'm using CMD, but I believe it happens with conemu and powershell, too).

mkalan commented 5 years ago

I too am having this exact same issue.

abinoam commented 5 years ago

I'll try to have a look as soon as possible. Meantime if someone come up with a patch, please submit a PR.

orgads commented 4 years ago

The problem is in io/console. This can demonstrate it as well:

require 'io/console'

c = nil
while c != "\r" && c != "\n"
  c = STDIN.getch
  STDERR.puts c.ord
end
orgads commented 4 years ago

https://github.com/ruby/io-console/issues/3

abinoam commented 4 years ago

Great @orgads so it's better to wait for a fix at io/console itself.

abinoam commented 1 year ago

https://github.com/ruby/io-console/issues/3 says it is solved and closed already.

Thank you all.