From 9f95efb21555b7618b19205c5ac648b21ba923f1 Mon Sep 17 00:00:00 2001 From: Trevin Chow Date: Fri, 15 May 2026 22:50:56 -0700 Subject: [PATCH] fix(skill): use portable trailing-XXXXXX mktemp form for plan tmpfiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Greptile's review flagged mktemp -t as non-portable between BSD and GNU. The suggested replacement (mktemp "$TMPDIR/...XXXXXX.json") is correct about dropping -t but still puts X's in the middle of the template name (XXXXXX.json), which BSD mktemp does not substitute — only X's at the end of the basename are replaced on BSD. Verified on macOS: mktemp "$TMPDIR/last30days-test.XXXXXX.json" → /var/folders/.../last30days-test.XXXXXX.json (X's left literal) The fully portable form uses trailing X's and drops the .json suffix (engine reads by path, not extension): mktemp "$TMPDIR/last30days-test.XXXXXX" → /var/folders/.../last30days-test.DXAHzR (X's substituted) Verified on bash and zsh, BSD/macOS. GNU/Linux is already fine since GNU substitutes X's wherever they appear in the basename. Applied to both --competitors-plan (comparison-mode block) and --plan (Step 1 block) tmpfile writes. --- skills/last30days/SKILL.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/skills/last30days/SKILL.md b/skills/last30days/SKILL.md index 44f838f..7b9d257 100644 --- a/skills/last30days/SKILL.md +++ b/skills/last30days/SKILL.md @@ -620,7 +620,9 @@ fi # avoids the inline-single-quoted-JSON apostrophe trap (resolved context # strings like "people's choice" or "McDonald's" otherwise close the outer # single-quote and break shell parsing before the engine is even invoked). -COMPETITORS_PLAN_FILE=$(mktemp -t last30days-competitors.XXXXXX.json) +# Trailing XXXXXX (no .json suffix) so BSD/macOS mktemp works the same as +# GNU; BSD only substitutes X's at the end of the template. +COMPETITORS_PLAN_FILE=$(mktemp "${TMPDIR:-/tmp}/last30days-competitors.XXXXXX") trap 'rm -f "$COMPETITORS_PLAN_FILE"' EXIT cat > "$COMPETITORS_PLAN_FILE" <<'PLAN_EOF' { @@ -960,8 +962,10 @@ fi # Write QUERY_PLAN_JSON to a tmpfile before the engine invocation above. # parse_plan() reads file paths transparently; this avoids inline-JSON # shell-quoting hazards (apostrophes in search_query / ranking_query -# strings break single-quoted command-line JSON). -QUERY_PLAN_FILE=$(mktemp -t last30days-plan.XXXXXX.json) +# strings break single-quoted command-line JSON). Trailing XXXXXX (no +# .json suffix) for BSD/macOS portability — BSD mktemp only substitutes +# X's at the end of the template. +QUERY_PLAN_FILE=$(mktemp "${TMPDIR:-/tmp}/last30days-plan.XXXXXX") trap 'rm -f "$QUERY_PLAN_FILE"' EXIT cat > "$QUERY_PLAN_FILE" <<'PLAN_EOF' {QUERY_PLAN_JSON_FROM_STEP_0.75}