Forum: Ruby Portable password input

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-03-13 15:56
(Received via mailing list)
This has been asked about before, and I've been wondering about it
myself. So I worked on it and came up with this. I know it's rather a
poor man's way of handling it but at least it's light and portable
(well, at least I think it is).

  def password( msg=nil )
    msg ||= "Enter Password"
    inp = ''

    i ={ inp = $stdin.gets }
    c = do
      loop do
        sleep 0.01
        $stdout << "\r#{msg}:        "
        $stdout << "\r#{msg}: "


    return inp
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2007-03-13 16:01
(Received via mailing list)
On Tue, 13 Mar 2007, Trans wrote:

>    c = do
>    return inp
>  end

gem install highline !!


4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2007-03-13 16:04
(Received via mailing list)
On Mar 13, 2007, at 10:00 AM, wrote:

>>    i.join
>>    return inp
>>  end
> gem install highline !!

I agree.  :)

James Edward Gray II
Eae21abfabb19c4617b2630386994fd9?d=identicon&s=25 greg (Guest)
on 2007-03-13 19:17
(Received via mailing list)
gem install highline
require 'highline/import'
ask('password: ') {|q| q.echo = '*' }
This topic is locked and can not be replied to.