Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
STDIN.getpass does not always show the key icon in the terminal

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.

enter image description here

How my code currently looks like:

  $stdout.flush
  # to hide the password while being typed in the terminal
  STDIN.getpass
  • I thought $stdout.flush would resolve my problem but it did not.
  • STDIN.getpass is being returned so its not assigned to any variables.
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!