How can I make sure that the key icon (see img for sample) always appears every time I call STDIN.getpass? The issue is intermittent, sometimes I get the icon and sometimes I don't. I could not find a reliable repro step.
How my code currently looks like:
$stdout.flush
# to hide the password while being typed in the terminal
STDIN.getpass
$stdout.flush would resolve my problem but it did not.STDIN.getpass is being returned so its not assigned to any variables.They key icon itself isn't so much related to the STDIN.getpass function which is very simple and you can see it here:
https://github.com/ruby/io-console/blob/master/lib/io/console/ffi/common.rb#L9-L21
the noecho block is just setting the tty_mode to noecho (see https://github.com/ruby/ruby/blob/d92f09a5eea009fa28cd046e9d0eb698e3d94c5c/ext/io/console/console.c#L602)
So, I think this question is actually better as: "How come my Terminal program on my operating system doesn't always show a key icon, when the tty_mode is set to noecho.