fix(skill): use portable trailing-XXXXXX mktemp form for plan tmpfiles
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.
This commit is contained in:
@@ -620,7 +620,9 @@ fi
|
|||||||
# avoids the inline-single-quoted-JSON apostrophe trap (resolved context
|
# avoids the inline-single-quoted-JSON apostrophe trap (resolved context
|
||||||
# strings like "people's choice" or "McDonald's" otherwise close the outer
|
# strings like "people's choice" or "McDonald's" otherwise close the outer
|
||||||
# single-quote and break shell parsing before the engine is even invoked).
|
# 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
|
trap 'rm -f "$COMPETITORS_PLAN_FILE"' EXIT
|
||||||
cat > "$COMPETITORS_PLAN_FILE" <<'PLAN_EOF'
|
cat > "$COMPETITORS_PLAN_FILE" <<'PLAN_EOF'
|
||||||
{
|
{
|
||||||
@@ -960,8 +962,10 @@ fi
|
|||||||
# Write QUERY_PLAN_JSON to a tmpfile before the engine invocation above.
|
# Write QUERY_PLAN_JSON to a tmpfile before the engine invocation above.
|
||||||
# parse_plan() reads file paths transparently; this avoids inline-JSON
|
# parse_plan() reads file paths transparently; this avoids inline-JSON
|
||||||
# shell-quoting hazards (apostrophes in search_query / ranking_query
|
# shell-quoting hazards (apostrophes in search_query / ranking_query
|
||||||
# strings break single-quoted command-line JSON).
|
# strings break single-quoted command-line JSON). Trailing XXXXXX (no
|
||||||
QUERY_PLAN_FILE=$(mktemp -t last30days-plan.XXXXXX.json)
|
# .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
|
trap 'rm -f "$QUERY_PLAN_FILE"' EXIT
|
||||||
cat > "$QUERY_PLAN_FILE" <<'PLAN_EOF'
|
cat > "$QUERY_PLAN_FILE" <<'PLAN_EOF'
|
||||||
{QUERY_PLAN_JSON_FROM_STEP_0.75}
|
{QUERY_PLAN_JSON_FROM_STEP_0.75}
|
||||||
|
|||||||
Reference in New Issue
Block a user