DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Terminal/
LocalPTYGetDefaultShell.rs1use serde_json::{Value, json};
8
9pub async fn Fn() -> Result<Value, String> {
10 #[cfg(unix)]
11 {
12 let Shell = std::env::var("SHELL").unwrap_or_else(|_| {
13 for Path in &["/bin/zsh", "/bin/bash", "/bin/sh"] {
14 if std::path::Path::new(Path).exists() {
15 return Path.to_string();
16 }
17 }
18 "/bin/sh".to_string()
19 });
20
21 Ok(json!(Shell))
22 }
23
24 #[cfg(target_os = "windows")]
25 {
26 let SystemRoot = std::env::var("SystemRoot").unwrap_or_else(|_| "C:\\Windows".to_string());
27
28 let PwshPath = format!("{}\\PowerShell\\7\\pwsh.exe", std::env::var("ProgramFiles").unwrap_or_default());
29
30 if std::path::Path::new(&PwshPath).exists() {
31 return Ok(json!(PwshPath));
32 }
33
34 Ok(json!(format!(
35 "{}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
36 SystemRoot
37 )))
38 }
39
40 #[cfg(not(any(unix, target_os = "windows")))]
41 {
42 Ok(json!("/bin/sh"))
43 }
44}