mirror of
https://github.com/openai/codex.git
synced 2026-09-06 15:29:32 +00:00
Avoid loading PowerShell profiles for tool commands
This commit is contained in:
@@ -52,10 +52,10 @@ impl Shell {
|
||||
}
|
||||
ShellType::PowerShell => {
|
||||
let mut args = vec![self.shell_path.to_string_lossy().to_string()];
|
||||
if !use_login_shell {
|
||||
args.push("-NoProfile".to_string());
|
||||
}
|
||||
|
||||
// PowerShell profiles can trigger sandbox-incompatible startup side effects,
|
||||
// so keep tool execution profile-free regardless of login-shell preference.
|
||||
let _ = use_login_shell;
|
||||
args.push("-NoProfile".to_string());
|
||||
args.push("-Command".to_string());
|
||||
args.push(command.to_string());
|
||||
args
|
||||
|
||||
@@ -142,7 +142,7 @@ fn derive_exec_args() {
|
||||
);
|
||||
assert_eq!(
|
||||
test_powershell_shell.derive_exec_args("echo hello", /*use_login_shell*/ true),
|
||||
vec!["pwsh.exe", "-Command", "echo hello"]
|
||||
vec!["pwsh.exe", "-NoProfile", "-Command", "echo hello"]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ fn test_get_command_respects_explicit_powershell_shell() -> anyhow::Result<()> {
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
|
||||
assert_eq!(command[2], "echo hello");
|
||||
assert!(command.contains(&"-NoProfile".to_string()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user