Skip to content

Commit

Permalink
feat: wait for password-command to exit
Browse files Browse the repository at this point in the history
useful for commands that requires interactive input
  • Loading branch information
istudyatuni committed Jun 22, 2023
1 parent f75a013 commit 4a994dc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/rustic_core/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
fs::File,
io::{BufRead, BufReader},
path::PathBuf,
process::Command,
process::{Command, Stdio},
};

use bytes::Bytes;
Expand Down Expand Up @@ -106,7 +106,7 @@ pub struct RepositoryOptions {
)]
pub password_file: Option<PathBuf>,

/// 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,
Expand Down Expand Up @@ -267,7 +267,11 @@ impl<P> Repository<P> {
.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());
};
Expand Down

0 comments on commit 4a994dc

Please sign in to comment.