Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix Windows shell detection for uppercase executable names (#66387)
M0_kiib41a8b60a470
diff --git a/crates/util/src/shell.rs b/crates/util/src/shell.rsindex 1c38707e7b2..65f68cdf506 100644--- a/crates/util/src/shell.rs+++ b/crates/util/src/shell.rs@@ -208,6 +208,11 @@ impl ShellKind {.file_stem().unwrap_or_else(|| program.as_os_str()).to_string_lossy();+ let program = if is_windows {+ Cow::Owned(program.to_ascii_lowercase())+ } else {+ program+ };match &*program {"powershell" => ShellKind::PowerShell,@@ -778,6 +783,44 @@ mod tests {#[cfg(unix)]use crate::shell_builder::ShellBuilder;+ #[test]+ fn test_shell_kind_windows_case_insensitive() {+ for (program, expected) in [+ ("CMD.EXE", ShellKind::Cmd),+ ("PowerShell.exe", ShellKind::PowerShell),+ ("PwSh.ExE", ShellKind::Pwsh),+ ("NU.EXE", ShellKind::Nushell),+ ("FISH.EXE", ShellKind::Fish),+ ("CSH.EXE", ShellKind::Csh),+ ("TCSH.EXE", ShellKind::Tcsh),+ ("RC.EXE", ShellKind::Rc),+ ("XONSH.EXE", ShellKind::Xonsh),+ ("ELVISH.EXE", ShellKind::Elvish),+ ("SH.EXE", ShellKind::Posix),+ ("BASH.EXE", ShellKind::Posix),+ ("ZSH.EXE", ShellKind::Posix),+ ("C:/Windows/System32/CMD.EXE", ShellKind::Cmd),+ ("C:/Program Files/PowerShell/7/PWSH.EXE", ShellKind::Pwsh),+ ("unknown.exe", ShellKind::PowerShell),+ ] {+ assert_eq!(ShellKind::new(program, true), expected, "{program}");+ }+ }++ #[test]+ fn test_shell_kind_unix_case_sensitive() {+ for (program, expected) in [+ ("/bin/nu", ShellKind::Nushell),+ ("/bin/NU", ShellKind::Posix),+ ("/bin/pwsh", ShellKind::Pwsh),+ ("/bin/PWSH", ShellKind::Posix),+ ("/bin/bash", ShellKind::Posix),+ ("/bin/unknown", ShellKind::Posix),+ ] {+ assert_eq!(ShellKind::new(program, false), expected, "{program}");+ }+ }+// Examples// WSL// wsl.exe --distribution NixOS --cd /home/user -- /usr/bin/zsh -c "echo hello"