Skip to content

Commit 3121353

Browse files
Avoid setting stdin handle when not necessary (helix-editor#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
1 parent c2a6d29 commit 3121353

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

helix-term/src/commands.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -4552,14 +4552,18 @@ fn shell_impl(
45524552
use std::process::{Command, Stdio};
45534553
ensure!(!shell.is_empty(), "No shell set");
45544554

4555-
let mut process = match Command::new(&shell[0])
4555+
let mut process = Command::new(&shell[0]);
4556+
process
45564557
.args(&shell[1..])
45574558
.arg(cmd)
4558-
.stdin(Stdio::piped())
45594559
.stdout(Stdio::piped())
4560-
.stderr(Stdio::piped())
4561-
.spawn()
4562-
{
4560+
.stderr(Stdio::piped());
4561+
4562+
if input.is_some() {
4563+
process.stdin(Stdio::piped());
4564+
}
4565+
4566+
let mut process = match process.spawn() {
45634567
Ok(process) => process,
45644568
Err(e) => {
45654569
log::error!("Failed to start shell: {}", e);

0 commit comments

Comments
 (0)