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:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user