util: Honor shell args for shell env fetching on windows (#44615)

Lukas Wirth created

Closes https://github.com/zed-industries/zed/issues/40464

Release Notes:

- Fixed shell environment fetching on windows discarding specified
arguments in settings

Change summary

crates/util/src/shell_env.rs | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

Detailed changes

crates/util/src/shell_env.rs 🔗

@@ -132,7 +132,7 @@ async fn spawn_and_read_fd(
 #[cfg(windows)]
 async fn capture_windows(
     shell_path: &Path,
-    _args: &[String],
+    args: &[String],
     directory: &Path,
 ) -> Result<collections::HashMap<String, String>> {
     use std::process::Stdio;
@@ -141,17 +141,17 @@ async fn capture_windows(
         std::env::current_exe().context("Failed to determine current zed executable path.")?;
 
     let shell_kind = ShellKind::new(shell_path, true);
-    if let ShellKind::Csh | ShellKind::Tcsh | ShellKind::Rc | ShellKind::Fish | ShellKind::Xonsh =
-        shell_kind
-    {
-        return Err(anyhow::anyhow!("unsupported shell kind"));
-    }
     let mut cmd = crate::command::new_smol_command(shell_path);
+    cmd.args(args);
     let cmd = match shell_kind {
-        ShellKind::Csh | ShellKind::Tcsh | ShellKind::Rc | ShellKind::Fish | ShellKind::Xonsh => {
-            unreachable!()
-        }
-        ShellKind::Posix => cmd.args([
+        ShellKind::Csh
+        | ShellKind::Tcsh
+        | ShellKind::Rc
+        | ShellKind::Fish
+        | ShellKind::Xonsh
+        | ShellKind::Posix => cmd.args([
+            "-l",
+            "-i",
             "-c",
             &format!(
                 "cd '{}'; '{}' --printenv",