mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
fix(shell) fallback shells (#6948)
## Summary Add fallbacks when user_shell_path does not resolve to a known shell type ## Testing - [x] Tests still pass
This commit is contained in:
@@ -204,10 +204,21 @@ pub async fn default_user_shell() -> Shell {
|
|||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
get_shell(ShellType::PowerShell, None).unwrap_or(Shell::Unknown)
|
get_shell(ShellType::PowerShell, None).unwrap_or(Shell::Unknown)
|
||||||
} else {
|
} else {
|
||||||
get_user_shell_path()
|
let user_default_shell = get_user_shell_path()
|
||||||
.and_then(|shell| detect_shell_type(&shell))
|
.and_then(|shell| detect_shell_type(&shell))
|
||||||
.and_then(|shell_type| get_shell(shell_type, None))
|
.and_then(|shell_type| get_shell(shell_type, None));
|
||||||
.unwrap_or(Shell::Unknown)
|
|
||||||
|
let shell_with_fallback = if cfg!(target_os = "macos") {
|
||||||
|
user_default_shell
|
||||||
|
.or_else(|| get_shell(ShellType::Zsh, None))
|
||||||
|
.or_else(|| get_shell(ShellType::Bash, None))
|
||||||
|
} else {
|
||||||
|
user_default_shell
|
||||||
|
.or_else(|| get_shell(ShellType::Bash, None))
|
||||||
|
.or_else(|| get_shell(ShellType::Zsh, None))
|
||||||
|
};
|
||||||
|
|
||||||
|
shell_with_fallback.unwrap_or(Shell::Unknown)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user