mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Fix quoted hook commands on Windows (#33926)
## Why Windows hook commands whose executable paths contain spaces fail when their outer quotes are escaped during argument construction. ## What changed - Pass hook command strings as raw arguments to the default Windows shell. - Do the same for configured shells that use the case-insensitive `/c` flag, while retaining normal argument handling for other shells. ## Testing Add a Windows regression test that runs a quoted `.cmd` hook from a directory with spaces through both the default shell and an explicit `COMSPEC /c` shell. GitOrigin-RevId: 0e7ce44203e01d3823daaaec750c2aeadfcd34b7
This commit is contained in:
@@ -168,9 +168,22 @@ fn build_command(shell: &CommandShell, handler: &ConfiguredHandler) -> Command {
|
||||
Command::new(&shell.program)
|
||||
};
|
||||
if shell.program.is_empty() {
|
||||
#[cfg(windows)]
|
||||
command.raw_arg(format!(r#""{}""#, handler.command));
|
||||
|
||||
#[cfg(not(windows))]
|
||||
command.arg(&handler.command);
|
||||
} else {
|
||||
command.args(&shell.args);
|
||||
|
||||
#[cfg(windows)]
|
||||
if shell.args.iter().any(|arg| arg.eq_ignore_ascii_case("/c")) {
|
||||
command.raw_arg(format!(r#""{}""#, handler.command));
|
||||
} else {
|
||||
command.arg(&handler.command);
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
command.arg(&handler.command);
|
||||
}
|
||||
command.envs(&handler.env);
|
||||
@@ -194,3 +207,7 @@ fn default_shell_command() -> Command {
|
||||
command
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, windows))]
|
||||
#[path = "command_runner_tests.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user