Skip to content

Commit

Permalink
Merge branch 'stuartnelson3-master'
Browse files Browse the repository at this point in the history
Closes #418
  • Loading branch information
mislav committed Nov 22, 2013
2 parents a894445 + 955b6aa commit 8e36335
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/hub/github_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,23 @@ def prompt_auth_code
File.exist?('/dev/null') ? '/dev/null' : 'NUL'

def askpass
noecho $stdin do |input|
input.gets.chomp
end
end

def noecho io
require 'io/console'
io.noecho { yield io }
rescue LoadError
fallback_noecho io
end

def fallback_noecho io
tty_state = `stty -g 2>#{NULL}`
system 'stty raw -echo -icanon isig' if $?.success?
pass = ''
while char = getbyte($stdin) and !(char == 13 or char == 10)
while char = getbyte(io) and !(char == 13 or char == 10)
if char == 127 or char == 8
pass[-1,1] = '' unless pass.empty?
else
Expand Down

0 comments on commit 8e36335

Please sign in to comment.