Skip to content

Commit

Permalink
Avoid setting stdin handle when not necessary (helix-editor#3248)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dariooddenino authored Aug 5, 2022
1 parent c2a6d29 commit 3121353
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3121353

Please sign in to comment.