Created
November 17, 2017 11:19
-
-
Save lobre/18ccd08aef0931d150bc9c253a7903d1 to your computer and use it in GitHub Desktop.
Process all gotpl templates to a destination with fallback on cp
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/ash | |
source=$1 | |
dest=$2 | |
if [[ -z "${source}" || -z "${dest}" ]]; then | |
echo "ERROR. Missing params!" | |
exit | |
fi | |
cd ${source} | |
for file in $(find -type f); do | |
if [[ ${file: -4} == ".tpl" ]] && [[ $(command -v gotpl) ]]; then | |
newfile=$dest/${file%.tpl} | |
mkdir -p -- $(dirname -- "$newfile") | |
gotpl $source/$file > $newfile | |
else | |
newfile=$dest/$file | |
mkdir -p -- $(dirname -- "$newfile") | |
cp $file $newfile | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment