diff options
| author | Paul Buetow <paul@buetow.org> | 2023-03-20 22:30:37 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-03-20 22:30:37 +0200 |
| commit | 04201e6226d1c0fe343fcc02914cb6250b8b890a (patch) | |
| tree | ff27d24e7844b209ef1cf10adb3725c2adf1a00d /lib | |
| parent | e16f05fd13428a20d939a82cee4761c214b0b5b0 (diff) | |
fix evil eval
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/template.source.sh | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/template.source.sh b/lib/template.source.sh index adc22a8..197caa5 100644 --- a/lib/template.source.sh +++ b/lib/template.source.sh @@ -35,7 +35,7 @@ template::_generate () { while IFS='' read -r line; do if [ "$is_block" = yes ]; then if [ "$line" = '>>>' ]; then - template::_eval "$block" + eval "$block" is_block=no block='' else @@ -46,7 +46,7 @@ $line" fi case "$line" in '<< '*) - template::_eval "$line" + template::_line "$line" ;; '<<<') is_block=yes @@ -58,18 +58,18 @@ $line" done } -template::_eval () { +template::_line () { eval "${1/<< /}" } template::test () { - assert::equals "$(template::_eval '<< echo -n foo')" 'foo' - assert::equals "$(template::_eval '<< echo foo')" 'foo' - assert::equals "$(template::_eval '<< $DATE --date @0 +%Y%m%d')" '19700101' - assert::equals "$(template::_eval '<< echo "$AUTHOR"')" "$AUTHOR" + assert::equals "$(template::_line '<< echo -n foo')" 'foo' + assert::equals "$(template::_line '<< echo foo')" 'foo' + assert::equals "$(template::_line '<< $DATE --date @0 +%Y%m%d')" '19700101' + assert::equals "$(template::_line '<< echo "$AUTHOR"')" "$AUTHOR" - template::_eval '<< foo=bar' - assert::equals "$(template::_eval '<< echo $foo')" bar + template::_line '<< foo=bar' + assert::equals "$(template::_line '<< echo $foo')" bar local -r template1='# Hello Mister <<< |
