aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Linskey2026-06-11 06:52:14 -0400
committerBenjamin Linskey2026-06-11 07:07:02 -0400
commitffd126df6dd6821d2b2b02d847abab6638aca2c1 (patch)
tree31eb133fc860937a7fc415d7414f1ead693a4a51
parentc1fedee8569ed98979c36d4e0803cd61ff5504fa (diff)
downloadtpl-ffd126df6dd6821d2b2b02d847abab6638aca2c1.tar.gz

Improve variable substitution efficiency

If a value in the variables file contains multiple instances of the same variable, they will all be replaced in a single function call, eliminating the need to loop over the same block of code multiple times.

-rwxr-xr-xtpl2
1 files changed, 1 insertions, 1 deletions
diff --git a/tpl b/tpl
index fb6ca1e..9461b6b 100755
--- a/tpl
+++ b/tpl
@@ -36,7 +36,7 @@ FILENAME == ARGV[1] && NF == 2 {
# Left braces must be escaped for strict POSIX compliance.
gsub(/\{/, "\\{", matched_text)
- sub(matched_text, vals[var_name], $2)
+ gsub(matched_text, vals[var_name], $2)
}
vals[$1] = $2