Highline: Can I "ask" to STDERR

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!

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 G. II

Perfect, thank you so much!

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