mirror of https://github.com/helix-editor/helix
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 fixpull/3340/head
parent
c2a6d29ffc
commit
3121353c6a
|
@ -4552,14 +4552,18 @@ fn shell_impl(
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
ensure!(!shell.is_empty(), "No shell set");
|
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..])
|
.args(&shell[1..])
|
||||||
.arg(cmd)
|
.arg(cmd)
|
||||||
.stdin(Stdio::piped())
|
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped());
|
||||||
.spawn()
|
|
||||||
{
|
if input.is_some() {
|
||||||
|
process.stdin(Stdio::piped());
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut process = match process.spawn() {
|
||||||
Ok(process) => process,
|
Ok(process) => process,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to start shell: {}", e);
|
log::error!("Failed to start shell: {}", e);
|
||||||
|
|
Loading…
Reference in New Issue