hiss/task/inject
2024-11-22 23:29:59 -07:00

26 lines
361 B
Bash
Executable File

#!/bin/sh
injection="$1"
tmp="$(mktemp)"
awk '
BEGIN {
s="<!-- start injection -->"
e="<!-- end injection -->"
}
FILENAME != "index.html" {
d=d $0 "\n"
next
}
$0 == s || $0 == e { print }
$0 == s,$0 == e {
if(d) {
printf d;
d = ""
}
next
}
{ print }
' "$injection" index.html > "$tmp" \
&& mv "$tmp" index.html