aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/user_interaction.rb34
1 files changed, 3 insertions, 31 deletions
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 1ab948dcb6..5db2dfd21c 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -224,41 +224,13 @@ class Gem::StreamUI
def ask_for_password(question)
return nil if not @ins.tty?
+ require 'io/console'
+
@outs.print(question + " ")
@outs.flush
- Gem.win_platform? ? ask_for_password_on_windows : ask_for_password_on_unix
- end
-
- ##
- # Asks for a password that works on windows. Ripped from the Heroku gem.
-
- def ask_for_password_on_windows
- require "Win32API"
- char = nil
- password = ''
-
- while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
- break if char == 10 || char == 13 # received carriage return or newline
- if char == 127 || char == 8 # backspace and delete
- password.slice!(-1, 1)
- else
- password << char.chr
- end
- end
-
- puts
- password
- end
-
- ##
- # Asks for a password that works on unix
-
- def ask_for_password_on_unix
- system "stty -echo"
- password = @ins.gets
+ password = @ins.noecho {@ins.gets}
password.chomp! if password
- system "stty echo"
password
end