hsmwebsite/template.awk
2024-11-19 22:51:41 +01:00

22 lines
335 B
Awk

# escaped lines
/^[ \t]*%/ {
i = index($0, "%");
print substr($0, i+1, length($0)-i);
next;
}
# inline code
/%\(.*%\)/ {
gsub(/'/, "\\'", $0);
gsub(/%\(.*%\)/, "';echo -n &;echo '", $0);
gsub(/%\(/, "", $0);
gsub(/%\)/, "", $0);
printf("echo -n '%s'\n", $0);
next;
}
{
gsub(/'/, "\\'", $0);
printf("echo '%s'\n", $0);
}