Use collect_output where possible

This commit is contained in:
Leonard Steppy 2025-01-08 13:43:05 +01:00
parent a932a9eb67
commit 51c8286565

View File

@ -18,7 +18,6 @@ use std::hash::Hash;
use std::io::Write; use std::io::Write;
use std::iter::once; use std::iter::once;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Stdio;
use std::str::FromStr; use std::str::FromStr;
use std::{env, fs}; use std::{env, fs};
@ -177,9 +176,8 @@ fn main() -> Result<(), String> {
let output = ShellCmd::new("ssh") let output = ShellCmd::new("ssh")
.arg(&server.ssh_name) .arg(&server.ssh_name)
.arg(osf!("ls ") + &working_directory) .arg(osf!("ls ") + &working_directory)
.stdout(Stdio::piped()) .collect_output()
.output() .map_err(|e| format!("failed to query files: {e}"))?;
.map_err(|e| format!("failed to query files via ssh: {e}"))?;
let output = String::from_utf8_lossy(&output.stdout); let output = String::from_utf8_lossy(&output.stdout);
let mut file_matcher = let mut file_matcher =
@ -401,8 +399,7 @@ fn start_ssh_agent(logger: &Logger) -> Result<(), String> {
//start the ssh agent //start the ssh agent
let agent_output = ShellCmd::new("ssh-agent") let agent_output = ShellCmd::new("ssh-agent")
.arg("-s") .arg("-s")
.stdout(Stdio::piped()) .collect_output()
.output()
.map_err(|e| format!("failed to start ssh agent: {e}"))?; .map_err(|e| format!("failed to start ssh agent: {e}"))?;
let agent_stdout = String::from_utf8_lossy(&agent_output.stdout); let agent_stdout = String::from_utf8_lossy(&agent_output.stdout);
if !agent_output.status.success() { if !agent_output.status.success() {
@ -417,7 +414,9 @@ fn start_ssh_agent(logger: &Logger) -> Result<(), String> {
} }
//add the ssh key //add the ssh key
ShellCmd::new("ssh-add").run(logger).map_err(|e| format!("failed to add ssh-key: {e}"))?; ShellCmd::new("ssh-add")
.run(logger)
.map_err(|e| format!("failed to add ssh-key: {e}"))?;
Ok(()) Ok(())
} }