Skip to content

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

fix(skill): preserve literal topics on macOS Bash 3.2 (#1240)

Tivonsicob29615e40741
diff --git a/changelog.d/+bash32-topic.fixed.md b/changelog.d/+bash32-topic.fixed.md
new file mode 100644
index 00000000..10a0251d
--- /dev/null
+++ b/changelog.d/+bash32-topic.fixed.md
@@ -0,0 +1 @@
+The research runbook passes literal topics containing apostrophes or backticks correctly on macOS Bash 3.2, while retaining zsh compatibility and preventing shell expansion.
diff --git a/skills/last30days/references/research-runbook.md b/skills/last30days/references/research-runbook.md
index 069c5ea7..bf4f4bb6 100644
--- a/skills/last30days/references/research-runbook.md
+++ b/skills/last30days/references/research-runbook.md
@@ -604,10 +604,13 @@ if [ ! -f "$SKILL_DIR/scripts/last30days.py" ]; then
exit 1
fi
-RESEARCH_TOPIC=$(cat <<'TOPIC_EOF'
+# Keep the quoted heredoc outside command substitution: macOS Bash 3.2
+# can misparse apostrophes/backticks in a heredoc nested inside $(...).
+IFS= read -r -d '' RESEARCH_TOPIC <<'TOPIC_EOF' || true
{TOPIC}
TOPIC_EOF
-)
+# read reaches EOF without a NUL delimiter; drop the heredoc's final newline.
+RESEARCH_TOPIC=${RESEARCH_TOPIC%$'\n'}
"${LAST30DAYS_PYTHON}" "${SKILL_DIR}/scripts/last30days.py" "$RESEARCH_TOPIC" --emit=compact --save-dir="${LAST30DAYS_MEMORY_DIR}" --save-suffix=v3
```
diff --git a/tests/test_skill_research_command.py b/tests/test_skill_research_command.py
index af8e1cad..30c5b581 100644
--- a/tests/test_skill_research_command.py
+++ b/tests/test_skill_research_command.py
@@ -4,6 +4,7 @@ import json
import os
import re
import shlex
+import shutil
import subprocess
import sys
@@ -13,11 +14,14 @@ import last30days as cli
from tests.skill_contract import reference_text
[email protected]("shell", ["bash", "zsh"])
@pytest.mark.parametrize("ambient_arguments", [None, "WRONG TOPIC --emit=json --save-dir=/wrong"])
@pytest.mark.parametrize("saving_enabled", [False, True])
def test_raw_research_recipe_preserves_the_topic_without_host_argument_expansion(
- tmp_path, ambient_arguments, saving_enabled,
+ tmp_path, ambient_arguments, saving_enabled, shell,
):
+ if not shutil.which(shell, path=os.defpath):
+ pytest.skip(f"{shell} is not installed")
reference = reference_text("research-runbook")
commands = [
block for block in re.findall(r"```bash\n(.*?)\n```", reference, re.S)
@@ -52,7 +56,7 @@ def test_raw_research_recipe_preserves_the_topic_without_host_argument_expansion
if ambient_arguments is not None:
env["ARGUMENTS"] = ambient_arguments
result = subprocess.run(
- ["bash", "-euC", "-c", command], cwd=tmp_path, env=env,
+ [shell, "-euC", "-c", command], cwd=tmp_path, env=env,
text=True, capture_output=True, timeout=15,
)