mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
## Why PowerShell's `-Command` can report a native command's exit code `2` as `1`, so a `PreToolUse` hook can fail to block a tool call. ## What changed Use `$?` to preserve successful hook results and forward `$LASTEXITCODE` on failure when available. Pass scripts with named blocks through as written because PowerShell forbids trailing top-level statements after those blocks. ## Testing Add Windows regression coverage for a native command and a PowerShell `end` block that each exit with code `2`. Both cases check that `PreToolUse` denies `apply_patch` before approval, reports the denial reason, and leaves the target file uncreated. GitOrigin-RevId: 9668b1382bb56f168794dd8d4d2fecac13d2f649