diff options
author | Dario Oddenino | 2022-08-05 02:15:50 +0000 |
---|---|---|
committer | GitHub | 2022-08-05 02:15:50 +0000 |
commit | 3121353c6ab2fbc5fced28f075c7fc45b53b661e (patch) | |
tree | bf9d5e8d514b3bb0a76ed152b65d1d913f9ab44c /helix-term/src | |
parent | c2a6d29ffc0f7696e6b8ea92029a956d37991c1e (diff) |
Avoid setting stdin handle when not necessary (#3248)
* Avoid setting stdin handle when not necessary
Avoid setting the stdin handle in `shell_impl` when the input argument
is None.
This permits to run commands with no stdin with :sh
* refactoring to avoid code duplication
* making clippy happy
* Process variable name fix
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index cd79cfb8..32f28004 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4552,14 +4552,18 @@ fn shell_impl( use std::process::{Command, Stdio}; ensure!(!shell.is_empty(), "No shell set"); - let mut process = match Command::new(&shell[0]) + let mut process = Command::new(&shell[0]); + process .args(&shell[1..]) .arg(cmd) - .stdin(Stdio::piped()) .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - { + .stderr(Stdio::piped()); + + if input.is_some() { + process.stdin(Stdio::piped()); + } + + let mut process = match process.spawn() { Ok(process) => process, Err(e) => { log::error!("Failed to start shell: {}", e); |