Fix sed portability: use temp file instead of sed -i

BSD sed (macOS) and GNU sed (Linux) interpret `sed -i ''`
differently — GNU treats the empty string as the script
argument, not the backup suffix. Replace with portable
sed-to-tmpfile-and-mv pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Taylor Eernisse
2026-02-08 15:23:18 -05:00
parent 482eb87b4c
commit 102d15cda7

View File

@@ -36,7 +36,7 @@ set_frontmatter() {
mv "$tmp" "$file"; return
fi
if grep -q "^${key}:" "$file"; then
sed -i '' "s|^${key}:.*|${key}: ${value}|" "$file"
sed "s|^${key}:.*|${key}: ${value}|" "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
else
awk -v key="$key" -v val="$value" '
BEGIN { count=0; inserted=0 }