Compare commits

...

1 Commits

Author SHA1 Message Date
David Wiesen
0f7b62f282 Avoid loading PowerShell profiles for tool commands 2026-05-11 09:12:50 -07:00
3 changed files with 6 additions and 5 deletions

View File

@@ -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

View File

@@ -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"]
);
}

View File

@@ -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(())
}