Method: Atom::Tools#obtain_password

Defined in:
lib/atom/tools.rb

#obtain_passwordObject

obtain a password from the TTY, hiding the user’s input this will fail if you don’t have the program ‘stty’



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/atom/tools.rb', line 133

def obtain_password
  i = o = File.open('/dev/tty', 'w+')

  o.print 'Password: '

  # store original settings
  state = `stty -F /dev/tty -g`

  # don't echo input
  system "stty -F /dev/tty -echo"

  p = i.gets.chomp

  # restore original settings
  system "stty -F /dev/tty #{state}"

  p
end