Skip to content

Instantly share code, notes, and snippets.

@lobre
Created November 17, 2017 11:19
Show Gist options
  • Save lobre/18ccd08aef0931d150bc9c253a7903d1 to your computer and use it in GitHub Desktop.
Save lobre/18ccd08aef0931d150bc9c253a7903d1 to your computer and use it in GitHub Desktop.
Process all gotpl templates to a destination with fallback on cp
#!/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