Commit 11cd3db1
11cd3db1ae58Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(spinel): mktemp -e mode leaks the no-.rb sibling file (#794)
spinel -e 'puts 42' ran mktemp /tmp/spinel_eval.XXXXXX (which
creates the file), then appended .rb to the variable -- so the
original empty file at /tmp/spinel_eval.XXXXXX leaked on every -e
invocation, while only the .rb sibling was wired up to the EXIT
trap.
Switch to mktemp -u (generate a unique name without creating the
file), then create the .rb file via the existing redirect.
Closes #794
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 11cd3db1ae58
- Parent
- 016a6ea41529
spinelmodifiedView file
@@ -129,7 +129,11 @@
129129
# .rb file were given, -e wins (consistent with `ruby -e ... script.rb`130130
# where the .rb file becomes ARGV — Spinel only consumes the source).131131
if [ "$EVAL_USED" -eq 1 ]; then132-
EVAL_TMP="$(mktemp /tmp/spinel_eval.XXXXXX).rb"132+
# Issue #794: mktemp creates the file; appending .rb to the variable133+
# leaves the original (no-.rb) file leaked. Use -u to skip file134+
# creation, then create the .rb directly via the redirect.135+
EVAL_BASE="$(mktemp -u /tmp/spinel_eval.XXXXXX)"136+
EVAL_TMP="${EVAL_BASE}.rb"133137
printf '%s\n' "$EVAL_SCRIPT" > "$EVAL_TMP"134138
SOURCE="$EVAL_TMP"135139
fi