Files
OthmanAdi 3c78c3ce44 fix: emit hook JSON with printf so a POSIX-mode shell cannot mangle it
Seven shell hooks build their JSON by interpolating a python json.dumps
result and emitting it with echo. bash's echo leaves the escapes alone, so
the hooks are correct when run through their own #!/bin/bash shebang. Run
them with sh on macOS, where /bin/sh is bash in POSIX mode with xpg_echo
set, and echo turns the escaped \n inside the string back into a real
newline, producing JSON with a raw control character that every parser
rejects.

printf '%s\n' never interprets backslashes in its argument, so the emitted
bytes are the same under every shell.

Reported by @dylanpulver while rebasing #226: the macOS failure of
test_copilot_shell_hooks_skip_context_when_disabled is this, not his
change. Diagnosis and the one-line repro were his.
2026-08-20 21:58:24 +02:00
..