Open
Description
The following code reads bytes from stdin and then enters the password:
use std::io::{self, Read};
use dialoguer::{theme::ColorfulTheme, Password};
fn main() {
let mut buf = Vec::new();
io::stdin().read_to_end(&mut buf).unwrap();
let passphrase = Password::with_theme(&ColorfulTheme::default())
.with_prompt("Enter passphrase")
.with_confirmation("Confirm passphrase", "Passphrases mismatch, try again")
.interact()
.unwrap();
println!("{buf:?}");
println!("{passphrase}");
}
This works well when the user enters bytes directly. However, when inputting bytes via redirect or pipe (e.g. echo "foo" | cmd
or cmd < infile
), this returns Bad file descriptor
when entering the password.
called `Result::unwrap()` on an `Err` value: IO(Os { code: 9, kind: Uncategorized, message: "Bad file descriptor" })
Metadata
Metadata
Assignees
Labels
No labels