Highline: Can I "ask" to STDERR

J

Jeremy Pruitt

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!
 
J

James Gray

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 =3D HighLine.new($stdin, $stderr)
ask( =85 )

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

hl =3D HighLine.new($stdin, $stderr)
hl.ask( =85 )

Hope that helps.

James Edward Gray II=
 
K

Ken Bloom

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top