diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-30 03:42:05 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-30 03:42:05 +0000 |
commit | 63a555ee4e3bb9e95bdee4c28b64b84e2536a249 (patch) | |
tree | 0aea217e291922f412e1ff9a5ff87762f2a5658d | |
parent | 2d8228c28e3604ff5ec533eaf73e81c349b15bf1 (diff) | |
download | ruby-63a555ee4e3bb9e95bdee4c28b64b84e2536a249.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/net/imap.rb | 10 |
2 files changed, 9 insertions, 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. [ruby-dev:41888] diff --git a/lib/net/imap.rb b/lib/net/imap.rb index fded6cc152..a032a1850d 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -3488,12 +3488,10 @@ EOF 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 @@ EOF 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 |