Skip to content

Commit b00a7cf

Browse files
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
1 parent 13d378f commit b00a7cf

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

codex-rs/core/src/shell.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,21 @@ pub async fn default_user_shell() -> Shell {
204204
if cfg!(windows) {
205205
get_shell(ShellType::PowerShell, None).unwrap_or(Shell::Unknown)
206206
} else {
207-
get_user_shell_path()
207+
let user_default_shell = get_user_shell_path()
208208
.and_then(|shell| detect_shell_type(&shell))
209-
.and_then(|shell_type| get_shell(shell_type, None))
210-
.unwrap_or(Shell::Unknown)
209+
.and_then(|shell_type| get_shell(shell_type, None));
210+
211+
let shell_with_fallback = if cfg!(target_os = "macos") {
212+
user_default_shell
213+
.or_else(|| get_shell(ShellType::Zsh, None))
214+
.or_else(|| get_shell(ShellType::Bash, None))
215+
} else {
216+
user_default_shell
217+
.or_else(|| get_shell(ShellType::Bash, None))
218+
.or_else(|| get_shell(ShellType::Zsh, None))
219+
};
220+
221+
shell_with_fallback.unwrap_or(Shell::Unknown)
211222
}
212223
}
213224

0 commit comments

Comments
 (0)