mikaelmello / inquire

A Rust library for building interactive prompts
https://docs.rs/inquire
MIT License
1.71k stars 72 forks source link

Password prompt with redirected `stdout` #247

Open cloudhead opened 2 months ago

cloudhead commented 2 months ago

When using a Password prompt with my stdout redirected, I get the error "the input device is not a TTY".

For example, let's say I have a program that takes a password and outputs to standard out, and I'd like to redirect that to a file:

$ my-program > output.txt

I'd expect to see:

$ my-program > output.txt
? Password: *****

But instead I get an error about the input device.

I think the issue here is that the password prompt is written to stdout instead of stderr. I thought this was fixed a while ago in #89 but maybe it was for other prompts?

Happy to look into this and open a PR if needed.