Skip to content

Commit

Permalink
Add force to mv in render_templates function
Browse files Browse the repository at this point in the history
  • Loading branch information
trnubo committed Feb 1, 2024
1 parent 6475632 commit c462c8d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions functions/render_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ render_templates() {
command -v gomplate >/dev/null 2>&1 || { error "This function requires gomplate to be installed."; return 1; }

for item in "${@}"; do
local item_dirname tempfile
[[ -e "${item}" ]] || { error "File ${item} is missing."; return 1; }
item_dirname="$(dirname "${item}")"
tempfile="$(mktemp -p "${item_dirname}" -t .tmp.XXXXXXXXXX)"
local item_dirname tempfile
[[ -e "${item}" ]] || { error "File ${item} is missing."; return 1; }
item_dirname="$(dirname "${item}")"
tempfile="$(mktemp -p "${item_dirname}" -t .tmp.XXXXXXXXXX)"
permissions="$(stat -c '%a' "${item}")"

(>&1 echo "Rendering template ${item}")
gomplate < "${item}" > "${tempfile}" || { rm "${tempfile}" 2>/dev/null; error "Failed to render template ${item}."; return 1; }
mv "${tempfile}" "${item/%\.tmpl/}"
mv -f "${tempfile}" "${item/%\.tmpl/}"
chmod "${permissions}" "${item/%\.tmpl/}"

if [[ "${DEBUG:-false}" == 'true' ]]; then
Expand Down

0 comments on commit c462c8d

Please # to comment.