import io

t = r"C:\Users\decid\Documents\projects\spt-claude-code\tests\mirror-public.sh"
s = io.open(t, encoding="utf-8").read()

bs = chr(92)  # a literal backslash, never written inline — a heredoc eats "\\n" into a real newline
old = "    printf '%s" + bs + "n' " + '"$out" | grep -i leak'
new = (
    "    # -A2: the guard prints the offending PATH on the line AFTER its LEAK header, and a bare\n"
    "    # `grep leak` drops exactly that line — leaving a failure that says something leaked but\n"
    "    # not what. Half an instrument reads like a whole one right up until you need it.\n"
    "    printf '%s" + bs + "n' " + '"$out" | grep -i -A2 leak'
)
assert s.count(old) == 1, s.count(old)
io.open(t, "w", encoding="utf-8", newline="\n").write(s.replace(old, new))
print("ok")
