Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix shell welcome prompt showing up in Zed's stdout (#41311)
Anthony Eid5e37a7b78c6e
diff --git a/clippy.toml b/clippy.tomlindex 4e9f2de8585..0ce7a6cd68d 100644--- a/clippy.toml+++ b/clippy.toml@@ -9,6 +9,9 @@ disallowed-methods = [{ path = "std::process::Command::spawn", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::spawn" },{ path = "std::process::Command::output", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::output" },{ path = "std::process::Command::status", reason = "Spawning `std::process::Command` can block the current thread for an unknown duration", replacement = "smol::process::Command::status" },+ { path = "std::process::Command::stdin", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stdin" },+ { path = "std::process::Command::stdout", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stdout" },+ { path = "std::process::Command::stderr", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stderr" },{ path = "serde_json::from_reader", reason = "Parsing from a buffer is much slower than first reading the buffer into a Vec/String, see https://github.com/serde-rs/json/issues/160#issuecomment-253446892. Use `serde_json::from_slice` instead." },{ path = "serde_json_lenient::from_reader", reason = "Parsing from a buffer is much slower than first reading the buffer into a Vec/String, see https://github.com/serde-rs/json/issues/160#issuecomment-253446892, Use `serde_json_lenient::from_slice` instead." },]diff --git a/crates/util/src/shell_env.rs b/crates/util/src/shell_env.rsindex b3c9e3bef39..179e8529d25 100644--- a/crates/util/src/shell_env.rs+++ b/crates/util/src/shell_env.rs@@ -33,7 +33,6 @@ async fn capture_unix(directory: &Path,) -> Result<collections::HashMap<String, String>> {use std::os::unix::process::CommandExt;- use std::process::Stdio;let shell_kind = ShellKind::new(shell_path, false);let zed_path = super::get_shell_safe_zed_path(shell_kind)?;@@ -56,9 +55,6 @@ async fn capture_unix(ShellKind::Xonsh => (FD_STDERR, "o>e".to_string()),_ => (FD_STDIN, format!(">&{}", FD_STDIN)), // `>&0`};- command.stdin(Stdio::null());- command.stdout(Stdio::piped());- command.stderr(Stdio::piped());match shell_kind {ShellKind::Csh | ShellKind::Tcsh => {@@ -107,7 +103,7 @@ async fn spawn_and_read_fd(child_fd: std::os::fd::RawFd,) -> anyhow::Result<(Vec<u8>, std::process::Output)> {use command_fds::{CommandFdExt, FdMapping};- use std::io::Read;+ use std::{io::Read, process::Stdio};let (mut reader, writer) = std::io::pipe()?;@@ -116,7 +112,11 @@ async fn spawn_and_read_fd(child_fd,}])?;- let process = smol::process::Command::from(command).spawn()?;+ let process = smol::process::Command::from(command)+ .stdin(Stdio::null())+ .stdout(Stdio::piped())+ .stderr(Stdio::piped())+ .spawn()?;let mut buffer = Vec::new();reader.read_to_end(&mut buffer)?;