From b94d4fc45ac05c129399ff9871ec41ebe3f2f004 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 1 Mar 2026 17:41:33 +0200 Subject: Replace set +u/set -u toggle with ${VAR:-} in html::theme::webfonts Using ${VAR:-} for potentially unset webfont variables keeps strict mode (set -u) active throughout the function, preventing silent bugs from unset variables in other parts of the code. Co-Authored-By: Claude Opus 4.6 --- lib/html.source.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/html.source.sh b/lib/html.source.sh index f772e22..fa9080f 100644 --- a/lib/html.source.sh +++ b/lib/html.source.sh @@ -95,35 +95,33 @@ html::theme::styles () { done < <(find "$html_base_dir" -mindepth 1 -maxdepth 1 -type d | $GREP -E -v '(\.git)') } +# Install theme webfonts, copying each configured font to the HTML output dir. +# Uses ${VAR:-} to safely handle potentially unset webfont variables under set -u. html::theme::webfonts () { local -r html_base_dir="$1"; shift log INFO 'Installing theme webfonts' - set +u - - if [ -f "$HTML_WEBFONT_TEXT" ]; then + if [ -f "${HTML_WEBFONT_TEXT:-}" ]; then cp "$HTML_WEBFONT_TEXT" "$html_base_dir/text.ttf" fi - if [ -f "$HTML_WEBFONT_HEADING" ]; then + if [ -f "${HTML_WEBFONT_HEADING:-}" ]; then cp "$HTML_WEBFONT_HEADING" "$html_base_dir/heading.ttf" - elif [ -f "$HTML_WEBFONT_TEXT" ]; then + elif [ -f "${HTML_WEBFONT_TEXT:-}" ]; then cp "$HTML_WEBFONT_TEXT" "$html_base_dir/heading.ttf" fi - if [ -f "$HTML_WEBFONT_CODE" ]; then + if [ -f "${HTML_WEBFONT_CODE:-}" ]; then cp "$HTML_WEBFONT_CODE" "$html_base_dir/code.ttf" fi - if [ -f "$HTML_WEBFONT_HANDNOTES" ]; then + if [ -f "${HTML_WEBFONT_HANDNOTES:-}" ]; then cp "$HTML_WEBFONT_HANDNOTES" "$html_base_dir/handnotes.ttf" fi - if [ -f "$HTML_WEBFONT_TYPEWRITER" ]; then + if [ -f "${HTML_WEBFONT_TYPEWRITER:-}" ]; then cp "$HTML_WEBFONT_TYPEWRITER" "$html_base_dir/typewriter.ttf" fi - - set -u } html::source_highlight () { -- cgit v1.2.3