fix: not printing stderr

This commit is contained in:
iff 2023-08-09 20:47:28 +02:00
parent 60616750ea
commit 0644b279a2
2 changed files with 25 additions and 10 deletions

View file

@ -58,7 +58,7 @@ fn main() {
let retry_message =
format!("{}", "Looking for new suggestion...".cyan().bold());
println!("\n{} {}", "ERROR:".red().bold(), msg);
// println!("\n{} {}", "ERROR:".red().bold(), msg);
println!("\n{}\n", retry_message);
}
} else {

View file

@ -197,15 +197,23 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
let process = std::process::Command::new(p)
.arg(shell)
.arg("-c")
.arg(command)
.arg(&command)
.stdout(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.expect("failed to execute process");
.stderr(Stdio::inherit())
.spawn()
.expect("failed to execute process")
.wait()
.unwrap();
if process.status.success() {
if process.success() {
return Ok(());
} else {
let process = std::process::Command::new(p)
.arg(shell)
.arg("-c")
.arg(command)
.output()
.expect("failed to execute process");
let error_msg = String::from_utf8_lossy(&process.stderr);
return Err(error_msg.to_string());
}
@ -216,13 +224,20 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
.arg("-c")
.arg(command)
.stdout(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.expect("failed to execute process");
.stderr(Stdio::inherit())
.spawn()
.expect("failed to execute process")
.wait()
.unwrap();
if process.status.success() {
if process.success() {
Ok(())
} else {
let process = std::process::Command::new(shell)
.arg("-c")
.arg(command)
.output()
.expect("failed to execute process");
let error_msg = String::from_utf8_lossy(&process.stderr);
Err(error_msg.to_string())
}