Created
June 30, 2018 19:00
-
-
Save vicentebolea/fe42e370175aeb462825a6b5e5e1f932 to your computer and use it in GitHub Desktop.
Simple BASH template engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| rules=$1 | |
| source $rules | |
| mapfile -t keywords < <(< $1 sed -n 's/^\([A-Za-z0-9_]\+\)=.*$/\1/p') | |
| while read line | |
| do | |
| for keyword in "${keywords[@]}" | |
| do | |
| line=`sed "s@\@${keyword}\@@${!keyword}@g" <<<"$line"` | |
| done | |
| echo $line | |
| done < /dev/stdin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment