Hello,

Please find attached a small patch improving shell detection on
OpenBSD.

It recognizes ksh as a POSIX-compatible shell and prefers the
base-system /bin/ksh or /bin/sh as the fallback.

This avoids requiring Bash or Zsh for normal command execution.

The patch reuses the existing ShellType::Sh implementation and
preserves explicitly selected user shells.

No additional dependencies or shell implementations are introduced.

Thanks,
David.
Index: devel/codex/patches/patch-codex-rs_shell-command_src_shell_detect_rs
===================================================================
RCS file: devel/codex/patches/patch-codex-rs_shell-command_src_shell_detect_rs
diff -N devel/codex/patches/patch-codex-rs_shell-command_src_shell_detect_rs
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ devel/codex/patches/patch-codex-rs_shell-command_src_shell_detect_rs	18 Oct 2026 16:10:35 -0000
@@ -0,0 +1,42 @@
+Minimal OpenBSD ksh preference: recognize ksh and prefer ksh/sh fallback over bash/zsh.
+Index: codex-rs/shell-command/src/shell_detect.rs
+--- codex-rs/shell-command/src/shell_detect.rs.orig
++++ codex-rs/shell-command/src/shell_detect.rs
+@@ -41,6 +41,7 @@ pub fn detect_shell_type(shell_path: imp
+     match shell_path.as_os_str().to_str() {
+         Some("zsh") => Some(ShellType::Zsh),
+         Some("sh") => Some(ShellType::Sh),
++        Some("ksh") => Some(ShellType::Sh),
+         Some("cmd") => Some(ShellType::Cmd),
+         Some("bash") => Some(ShellType::Bash),
+         Some("pwsh") => Some(ShellType::PowerShell),
+@@ -250,9 +251,15 @@ fn get_bash_shell() -> Option<DetectedSh
+     })
+ }
+ 
++#[cfg(target_os = "openbsd")]
++const SH_FALLBACK_PATHS: &[&str] = &["/bin/ksh", "/bin/sh"];
++#[cfg(not(target_os = "openbsd"))]
+ const SH_FALLBACK_PATHS: &[&str] = &["/bin/sh"];
+ 
+ fn get_sh_shell() -> Option<DetectedShell> {
++    #[cfg(target_os = "openbsd")]
++    let shell_path = get_shell_path(ShellType::Sh, "ksh", SH_FALLBACK_PATHS);
++    #[cfg(not(target_os = "openbsd"))]
+     let shell_path = get_shell_path(ShellType::Sh, "sh", SH_FALLBACK_PATHS);
+ 
+     shell_path.map(|shell_path| DetectedShell {
+@@ -372,6 +379,13 @@ pub fn default_user_shell_from_path(user
+             user_default_shell
+                 .or_else(|| get_shell(ShellType::Zsh))
+                 .or_else(|| get_shell(ShellType::Bash))
++        } else if cfg!(target_os = "openbsd") {
++            // Prefer the platform ksh/sh over bash/zsh when the user shell is
++            // not a recognized explicit choice. An explicit bash/zsh stays.
++            user_default_shell
++                .or_else(|| get_shell(ShellType::Sh))
++                .or_else(|| get_shell(ShellType::Bash))
++                .or_else(|| get_shell(ShellType::Zsh))
+         } else {
+             user_default_shell
+                 .or_else(|| get_shell(ShellType::Bash))

Reply via email to