util: Fix shell kind in windows based on program path (#39696)
Closes #39614 The `ShellKind` struct is built on Windows' side, meaning that when connecting to remotes, we fall back to PowerShell construction, even if the shell program we are spawning is a unix program. This broke tasks creation since we are using the shell kind to construct args: https://github.com/zed-industries/zed/blob/d04ac864b8cb78ee888ce03323e34c17a6dd16b9/crates/project/src/terminals.rs#L149 In normal terminals this only affected activation scripts (only place where shell kind is used) I don't have a Windows machine to test it, so I would appreciate any help with testing! Release Notes: - Fixed an issue where tasks could not be executed in Windows WSL --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
This commit is contained in:
@@ -173,18 +173,16 @@ impl fmt::Display for ShellKind {
|
||||
|
||||
impl ShellKind {
|
||||
pub fn system() -> Self {
|
||||
Self::new(&get_system_shell())
|
||||
Self::new(&get_system_shell(), cfg!(windows))
|
||||
}
|
||||
|
||||
pub fn new(program: impl AsRef<Path>) -> Self {
|
||||
pub fn new(program: impl AsRef<Path>, is_windows: bool) -> Self {
|
||||
let program = program.as_ref();
|
||||
let Some(program) = program.file_stem().and_then(|s| s.to_str()) else {
|
||||
return if cfg!(windows) {
|
||||
ShellKind::PowerShell
|
||||
} else {
|
||||
ShellKind::Posix
|
||||
};
|
||||
};
|
||||
let program = program
|
||||
.file_stem()
|
||||
.unwrap_or_else(|| program.as_os_str())
|
||||
.to_string_lossy();
|
||||
|
||||
if program == "powershell" || program == "pwsh" {
|
||||
ShellKind::PowerShell
|
||||
} else if program == "cmd" {
|
||||
@@ -204,7 +202,7 @@ impl ShellKind {
|
||||
} else if program == "sh" || program == "bash" {
|
||||
ShellKind::Posix
|
||||
} else {
|
||||
if cfg!(windows) {
|
||||
if is_windows {
|
||||
ShellKind::PowerShell
|
||||
} else {
|
||||
// Some other shell detected, the user might install and use a
|
||||
|
||||
Reference in New Issue
Block a user