Forum: Ruby Highline: Can I "ask" to STDERR

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
31fd5c345c79766f3adebaa8120b8411?d=identicon&s=25 Jeremy Pruitt (jeremypruitt)
on 2008-10-06 01:05
Hello, fellow ruby enthusiasts! I'm a first time caller, long time
listener.

Does highline allow you to send the "ask" prompt to STDERR? I often
times use it to prompt for passwords in command line tools that I want
to pipe to less or more. The problem is that if I pipe it to less or
more I never see the password prompt, and I believe the usual workaround
is to send the password prompt to STDERR to get around this.

Any ideas?

 - Thanks!
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2008-10-06 04:22
(Received via mailing list)
On Oct 5, 2008, at 6:03 PM, Jeremy Pruitt wrote:

> Hello, fellow ruby enthusiasts! I'm a first time caller, long time
> listener.

Glad you decided to join us.

> Does highline allow you to send the "ask" prompt to STDERR?

Sure.  If using the import interface, you can do it like this:

$terminal = HighLine.new($stdin, $stderr)
ask( … )

Otherwise, you can just build the proper HighLine instance and use it:

hl = HighLine.new($stdin, $stderr)
hl.ask( … )

Hope that helps.

James Edward Gray II
31fd5c345c79766f3adebaa8120b8411?d=identicon&s=25 Jeremy Pruitt (jeremypruitt)
on 2008-10-06 04:37
Perfect, thank you so much!
851acbab08553d1f7aa3eecad17f6aa9?d=identicon&s=25 Ken Bloom (Guest)
on 2008-10-13 01:11
(Received via mailing list)
On Sun, 05 Oct 2008 21:35:29 -0500, Jeremy Pruitt wrote:

> Perfect, thank you so much!

By the way, a little known Linux trick is that if you can read from
stderr too. So if you want to have an interactive filter in a pipeline,
that reads from stdin and writes to stdout, you can have it do all of
it's interaction (both ways) on stderr to read from the terminal.

That's how `vim -' works

--Ken
This topic is locked and can not be replied to.