Resolve model-provided shells by type (#39607)

## Why

A model-provided shell path should select the requested shell type without
allowing that path to determine which executable Codex runs.

## What changed

- Resolve model-provided shells through Codex's normal shell discovery and
  fallback logic after detecting their type.
- Keep the configured packaged zsh executable when the zsh-fork feature is
  enabled and the file exists.
- Update shell, unified exec, and network approval expectations to use the
  resolved local executable and arguments.

GitOrigin-RevId: ebe6f7eec2cfd1c0548d5bf1a26b7a30dba02cc2
This commit is contained in:
pakrym-oai authored and copyberry committed 2026-08-20 06:03:25 +00:00
1 parent 6869d17cc2
commit 186b449bc2
9 files changed
+73 -422

No files matched your search

+9 -9
View File
@@ -5,7 +5,7 @@ use std::process::Command;
#[test]
#[cfg(target_os = "macos")]
fn detects_zsh() {
let zsh_shell = get_shell(ShellType::Zsh, /*path*/ None).unwrap();
let zsh_shell = get_shell(ShellType::Zsh).unwrap();
let shell_path = zsh_shell.shell_path;
@@ -24,7 +24,7 @@ fn fish_fallback_to_zsh() {
#[test]
fn detects_bash() {
let bash_shell = get_shell(ShellType::Bash, /*path*/ None).unwrap();
let bash_shell = get_shell(ShellType::Bash).unwrap();
let shell_path = bash_shell.shell_path;
assert!(
@@ -35,7 +35,7 @@ fn detects_bash() {
#[test]
fn detects_sh() {
let sh_shell = get_shell(ShellType::Sh, /*path*/ None).unwrap();
let sh_shell = get_shell(ShellType::Sh).unwrap();
let shell_path = sh_shell.shell_path;
assert!(
shell_path.file_name().and_then(|name| name.to_str()) == Some("sh"),
@@ -48,12 +48,12 @@ fn can_run_on_shell_test() {
let cmd = "echo \"Works\"";
if cfg!(windows) {
assert!(shell_works(
get_shell(ShellType::PowerShell, /*path*/ None),
get_shell(ShellType::PowerShell),
"Out-String 'Works'",
/*required*/ true,
));
assert!(shell_works(
get_shell(ShellType::Cmd, /*path*/ None),
get_shell(ShellType::Cmd),
cmd,
/*required*/ true,
));
@@ -69,17 +69,17 @@ fn can_run_on_shell_test() {
/*required*/ true
));
assert!(shell_works(
get_shell(ShellType::Zsh, /*path*/ None),
get_shell(ShellType::Zsh),
cmd,
/*required*/ false
));
assert!(shell_works(
get_shell(ShellType::Bash, /*path*/ None),
get_shell(ShellType::Bash),
cmd,
/*required*/ true
));
assert!(shell_works(
get_shell(ShellType::Sh, /*path*/ None),
get_shell(ShellType::Sh),
cmd,
/*required*/ true
));
@@ -181,7 +181,7 @@ fn finds_powershell() {
return;
}
let powershell_shell = get_shell(ShellType::PowerShell, /*path*/ None).unwrap();
let powershell_shell = get_shell(ShellType::PowerShell).unwrap();
let shell_path = powershell_shell.shell_path;
assert!(shell_path.ends_with("pwsh.exe") || shell_path.ends_with("powershell.exe"));