mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/imap.rb (example): use IO#noecho to read password if
possible, and defer until needed. [ruby-dev:41889] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2d8228c28e
commit
63a555ee4e
2 changed files with 9 additions and 6 deletions
|
@ -1,4 +1,7 @@
|
||||||
Fri Jul 30 12:38:22 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Jul 30 12:42:02 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/net/imap.rb (example): use IO#noecho to read password if
|
||||||
|
possible, and defer until needed. [ruby-dev:41889]
|
||||||
|
|
||||||
* lib/net/imap.rb (example): support starttls option.
|
* lib/net/imap.rb (example): support starttls option.
|
||||||
[ruby-dev:41888]
|
[ruby-dev:41888]
|
||||||
|
|
|
@ -3488,12 +3488,10 @@ EOF
|
||||||
|
|
||||||
def get_password
|
def get_password
|
||||||
print "password: "
|
print "password: "
|
||||||
system("stty", "-echo")
|
|
||||||
begin
|
begin
|
||||||
return gets.chop
|
return _noecho(&:gets).chomp
|
||||||
ensure
|
ensure
|
||||||
system("stty", "echo")
|
puts
|
||||||
print "\n"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3546,7 +3544,9 @@ EOF
|
||||||
imap = Net::IMAP.new($host, :port => $port, :ssl => $ssl)
|
imap = Net::IMAP.new($host, :port => $port, :ssl => $ssl)
|
||||||
begin
|
begin
|
||||||
imap.starttls if $starttls
|
imap.starttls if $starttls
|
||||||
password = get_password
|
class << password = method(:get_password)
|
||||||
|
alias to_str call
|
||||||
|
end
|
||||||
imap.authenticate($auth, $user, password)
|
imap.authenticate($auth, $user, password)
|
||||||
while true
|
while true
|
||||||
cmd, *args = get_command
|
cmd, *args = get_command
|
||||||
|
|
Loading…
Reference in a new issue