This has been asked about before, and I’ve been wondering about it
myself. So I worked on it and came up with this. I know it’s rather a
poor man’s way of handling it but at least it’s light and portable
(well, at least I think it is).
def password( msg=nil )
msg ||= “Enter Password”
inp = ‘’
i = Thread.new{ inp = $stdin.gets }
c = Thread.new do
loop do
sleep 0.01
$stdout << "\r#{msg}: "
$stdout << "\r#{msg}: "
$stdout.flush
end
end
i.join
return inp
end