aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Linskey2026-06-07 12:51:13 -0400
committerBenjamin Linskey2026-06-07 19:50:56 -0400
commit1cedfb65dc3a2a6428e7492ed61c2060a9844810 (patch)
treef02a67a3841d067b9c722c0f98979dcb8847ca2f
parent2aa8ed870cb212328563b8a300b3a3b6754ce4e6 (diff)
downloadtpl-1cedfb65dc3a2a6428e7492ed61c2060a9844810.tar.gz

Add a note about regex metacharacter escaping

-rwxr-xr-xtpl5
1 files changed, 5 insertions, 0 deletions
diff --git a/tpl b/tpl
index 0db0604..56fe958 100755
--- a/tpl
+++ b/tpl
@@ -32,6 +32,11 @@ FILENAME == ARGV[1] && NF == 2 {
match(matched_text, /[^\{\}[:space:]]+/)
var_name = substr(matched_text, RSTART, RLENGTH)
+ # Even though matched_text contains the { and } regex
+ # metacharacters, we don't need to escape them because they're
+ # not used in a way that matches the (r){m,n} syntax.
+ # (We don't need to escape them elsewhere in this program
+ # either, but we do so for maximum clarity.)
sub(matched_text, vals[var_name], $2)
}