Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add force to mv in render_templates function #7

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading