[Feature:trunk] improvement of sample in lib/imap.rb: password input

[email protected]$G$9!#e(B

lib/net/imap.rbe$B$rD>@<B9T$9$k$H;H$($k4J0We(BIMAPe$B%/%i%$%"%s%H$r!"%Qe(B
e$B%9%o!<%I$NF~NO$Ke(BIO#noechoe$B$r;H$&$h$&$K$7$F$_$^$7$?!#$^$?!"<B:]$Ke(B
e$BI,MW$K$J$k$^$G%Q%9%o!<%I$NF~NO$rCY$i$;$k$h$&$K$b$7$F$$$^$9!#e(B

Index: lib/net/imap.rb

— lib/net/imap.rb (revision 28780)
+++ lib/net/imap.rb (working copy)
@@ -3485,12 +3485,27 @@
end

  • begin
  • require ‘io/console’
  • rescue LoadError
  • def _noecho(&block)
  •  system("stty", "-echo")
    
  •  begin
    
  •    yield STDIN
    
  •  ensure
    
  •    system("stty", "echo")
    
  •  end
    
  • end
  • else
  • def _noecho(&block)
  •  STDIN.noecho(&block)
    
  • end
  • end
  • 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
    @@ -3543,5 +3558,7 @@
    imap = Net::IMAP.new($host, :port => $port, :ssl => $ssl)
    begin
  • password = get_password
  • class << password = method(:get_password)
  •  alias to_str call
    
  • end
    imap.authenticate($auth, $user, password)
    while true

e$BA0ED$G$9!#e(B

2010e$BG/e(B7e$B7ne(B29e$BF|e(B12:17 Nobuyoshi N.
[email protected]:

lib/net/imap.rbe$B$rD>@<B9T$9$k$H;H$($k4J0We(BIMAPe$B%/%i%$%"%s%H$r!"%Qe(B
e$B%9%o!<%I$NF~NO$Ke(BIO#noechoe$B$r;H$&$h$&$K$7$F$_$^$7$?!#$^$?!"<B:]$Ke(B
e$BI,MW$K$J$k$^$G%Q%9%o!<%I$NF~NO$rCY$i$;$k$h$&$K$b$7$F$$$^$9!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#e([email protected]$1$^$9$+e(B?

e$B%A%1%C%He(B #3626 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

This issue was solved with changeset r28798.
Nobuyoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


http://redmine.ruby-lang.org/issues/show/3626

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs