From 74d1bdfce58b074cbab9673aa2b792d428d1b74b Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 11 Jan 2022 21:34:34 +0100 Subject: [PATCH] fix(terminal): Do not invoke read command on shell execution --- plugins/src/terminal/mod.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/src/terminal/mod.rs b/plugins/src/terminal/mod.rs index 0288bfe..4dd0fa4 100644 --- a/plugins/src/terminal/mod.rs +++ b/plugins/src/terminal/mod.rs @@ -44,8 +44,8 @@ pub async fn main() { impl App { async fn activate(&mut self, _id: u32) { - let exec = match self.last_query.take() { - Some(cmd) => format!("{}; echo \"Press Enter to exit\"; read t", cmd), + let exe = match self.last_query.take() { + Some(cmd) => cmd, None => return, }; @@ -53,7 +53,7 @@ impl App { crate::send(&mut self.out, PluginResponse::Close).await; - if let Ok(Fork::Child) = daemon(true, true) { + if let Ok(Fork::Child) = daemon(true, false) { use std::os::unix::process::CommandExt; use std::process::Command; @@ -61,16 +61,22 @@ impl App { if self.shell_only { cmd = Command::new("sh"); - cmd.args(&["-c", &exec]); + cmd.args(&["-c", &exe]); } else { let (terminal, arg) = detect_terminal(); cmd = Command::new(terminal); - cmd.args(&[arg, "sh", "-c", &exec]); + cmd.args(&[ + arg, + "sh", + "-c", + &format!("{}; echo \"Press Enter to exit\"; read t", exe), + ]); } let _ = cmd.exec(); - std::process::exit(1); } + + std::process::exit(0); } async fn search(&mut self, query: String) {