mirror of
https://github.com/openai/codex.git
synced 2026-02-01 22:47:52 +00: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) {
|
||||
get_shell(ShellType::PowerShell, None).unwrap_or(Shell::Unknown)
|
||||
} else {
|
||||
get_user_shell_path()
|
||||
let user_default_shell = get_user_shell_path()
|
||||
.and_then(|shell| detect_shell_type(&shell))
|
||||
.and_then(|shell_type| get_shell(shell_type, None))
|
||||
.unwrap_or(Shell::Unknown)
|
||||
.and_then(|shell_type| get_shell(shell_type, None));
|
||||
|
||||
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