mirror of
https://github.com/openai/codex.git
synced 2026-09-20 12:47:38 +00:00
unified-exec: launch remote commands without host sandbox
This commit is contained in:
@@ -225,6 +225,27 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prefixes_windows_powershell_path_on_a_foreign_host() {
|
||||
let shell = r"C:\Program Files\PowerShell\7\pwsh.exe";
|
||||
let cmd = vec![
|
||||
shell.to_string(),
|
||||
"-NoProfile".to_string(),
|
||||
"-Command".to_string(),
|
||||
"Write-Host hi".to_string(),
|
||||
];
|
||||
|
||||
assert_eq!(
|
||||
prefix_powershell_script_with_utf8(&cmd),
|
||||
vec![
|
||||
shell.to_string(),
|
||||
"-NoProfile".to_string(),
|
||||
"-Command".to_string(),
|
||||
format!("{UTF8_OUTPUT_PREFIX}Write-Host hi"),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_duplicate_utf8_prefix() {
|
||||
let cmd = vec![
|
||||
|
||||
@@ -38,6 +38,12 @@ impl DetectedShell {
|
||||
|
||||
pub fn detect_shell_type(shell_path: impl AsRef<std::path::Path>) -> Option<ShellType> {
|
||||
let shell_path = shell_path.as_ref();
|
||||
if let Some(path) = shell_path.as_os_str().to_str()
|
||||
&& let Some(file_name) = path.rsplit(['/', '\\']).next()
|
||||
&& file_name != path
|
||||
{
|
||||
return detect_shell_type(PathBuf::from(file_name));
|
||||
}
|
||||
match shell_path.as_os_str().to_str() {
|
||||
Some("zsh") => Some(ShellType::Zsh),
|
||||
Some("sh") => Some(ShellType::Sh),
|
||||
@@ -347,6 +353,12 @@ mod tests {
|
||||
detect_shell_type(PathBuf::from("pwsh.exe")),
|
||||
Some(ShellType::PowerShell)
|
||||
);
|
||||
assert_eq!(
|
||||
detect_shell_type(PathBuf::from(
|
||||
r"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
|
||||
)),
|
||||
Some(ShellType::PowerShell)
|
||||
);
|
||||
assert_eq!(
|
||||
detect_shell_type(PathBuf::from("/usr/local/bin/pwsh")),
|
||||
Some(ShellType::PowerShell)
|
||||
|
||||
Reference in New Issue
Block a user