From f27e901302c8294370ac77bfba148c7d72bc8b78 Mon Sep 17 00:00:00 2001 From: Drew Ritter Date: Thu, 26 Nov 2026 00:46:07 -0800 Subject: docs(hooks): show how to read the escaping example's result The example's escape_for_json, copied from hooks/session-start, leaves its result in using_superpowers_escaped and prints nothing, but the block shows no call, so a hook author who copies it and writes json=$(escape_for_json "$text") gets an empty string and no error. Add a comment after the function that says why the result is left in a variable (capturing output with $(...) forks) and shows the call followed by the read of the variable. Co-Authored-By: Claude Opus 5.5 --- docs/windows/polyglot-hooks.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docs') diff --git a/docs/windows/polyglot-hooks.md b/docs/windows/polyglot-hooks.md index 7a54aa8..d6970e1 100644 --- a/docs/windows/polyglot-hooks.md +++ b/docs/windows/polyglot-hooks.md @@ -209,6 +209,11 @@ escape_for_json() { replace_all "$escaped" "$tab" '\t' using_superpowers_escaped=$escaped } + +# The result is left in a variable instead of printed, because capturing +# output with $(...) forks. Call the function, then read the variable: +# escape_for_json "$content" +# json=$using_superpowers_escaped ``` ## Troubleshooting -- cgit