From 4a994dcf221d820ec8d82f246daf85b32e2a998a Mon Sep 17 00:00:00 2001 From: Ilia Date: Thu, 22 Jun 2023 18:50:18 +0300 Subject: [PATCH] feat: wait for password-command to exit useful for commands that requires interactive input --- crates/rustic_core/src/repository.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/rustic_core/src/repository.rs b/crates/rustic_core/src/repository.rs index 973b18fbf..e8fe8cf33 100644 --- a/crates/rustic_core/src/repository.rs +++ b/crates/rustic_core/src/repository.rs @@ -3,7 +3,7 @@ use std::{ fs::File, io::{BufRead, BufReader}, path::PathBuf, - process::Command, + process::{Command, Stdio}, }; use bytes::Bytes; @@ -106,7 +106,7 @@ pub struct RepositoryOptions { )] pub password_file: Option, - /// Command to read the password from + /// Command to read the password from. Password is read from stdout #[cfg_attr(feature = "clap", clap( long, global = true, @@ -267,7 +267,11 @@ impl

Repository

{ .map_err(RepositoryErrorKind::FromNomError)? .1; debug!("commands: {commands:?}"); - let Ok(output) = Command::new(commands[0]).args(&commands[1..]).output() else { + let command = Command::new(commands[0]) + .args(&commands[1..]) + .stdout(Stdio::piped()) + .spawn()?; + let Ok(output) = command.wait_with_output() else { return Err( RepositoryErrorKind::PasswordCommandParsingFailed.into()); };