Refactor _f_last_updated

This commit is contained in:
Stig-Ørjan Smelror 2024-02-12 23:09:17 +01:00
parent 48b2f30ea7
commit 0ff85c7128

15
qsgen2
View File

@ -430,23 +430,26 @@ function _f_last_updated() {
local debug=true local debug=true
fi fi
local file_path="${1}" # local file_path="${1}"
local upd_msg="Last updated ${today} by <a href=\"https://blog.kekepower.com/qsgen2.html\">${QSGEN} ${VERSION}</a>" local upd_msg="Last updated ${today} by <a href=\"https://blog.kekepower.com/qsgen2.html\">${QSGEN} ${VERSION}</a>"
if ${debug}; then if ${debug}; then
_msg debug "_f_last_updated: Setting date and version in footer of file ${file_path}" _msg debug "_f_last_updated: Setting date and version in footer of file ${1}"
_msg debug "_f_last_updated: ${upd_msg}" _msg debug "_f_last_updated: ${upd_msg}"
fi fi
# Read the file content into a variable # Read the file content into a variable
local content="$(<${file_path})" local content="$(<${1})"
# Perform the replacement # Perform the replacement
content="${content//#updated/${upd_msg}}" content="${content//#updated/${upd_msg}}"
sed -i '' -e "s|#updated|${upd_msg}|" "${file_path}" if [[ -f "${1}" ]]; then
# Write the updated content back to the file sed -i -e "s|#updated|${upd_msg}|" "${1}"
#print -r -- "$content" >| "${file_path}" else
_msg debug "_f_last_updated: File '${1}' not found."
fi
} }
function _file_to_lower() { function _file_to_lower() {