ruby-changes:16803
From: nobu <ko1@a...>
Date: Fri, 30 Jul 2010 13:01:15 +0900 (JST)
Subject: [ruby-changes:16803] Ruby:r28798 (trunk): * lib/net/imap.rb (example): use IO#noecho to read password if
nobu 2010-07-30 12:42:05 +0900 (Fri, 30 Jul 2010) New Revision: 28798 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28798 Log: * lib/net/imap.rb (example): use IO#noecho to read password if possible, and defer until needed. [ruby-dev:41889] Modified files: trunk/ChangeLog trunk/lib/net/imap.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 28797) +++ ChangeLog (revision 28798) @@ -1,5 +1,8 @@ -Fri Jul 30 12:38:22 2010 Nobuyoshi Nakada <nobu@r...> +Fri Jul 30 12:42:02 2010 Nobuyoshi Nakada <nobu@r...> + * 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. [ruby-dev:41888] Index: lib/net/imap.rb =================================================================== --- lib/net/imap.rb (revision 28797) +++ lib/net/imap.rb (revision 28798) @@ -3488,12 +3488,10 @@ def get_password print "password: " - system("stty", "-echo") begin - return gets.chop + return _noecho(&:gets).chomp ensure - system("stty", "echo") - print "\n" + puts end end @@ -3546,7 +3544,9 @@ imap = Net::IMAP.new($host, :port => $port, :ssl => $ssl) begin imap.starttls if $starttls - password = get_password + class << password = method(:get_password) + alias to_str call + end imap.authenticate($auth, $user, password) while true cmd, *args = get_command -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/