summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-01 17:41:33 +0200
committerPaul Buetow <paul@buetow.org>2026-03-01 17:41:33 +0200
commitb94d4fc45ac05c129399ff9871ec41ebe3f2f004 (patch)
treea14672215dbb91f3922de6424f1137d800d3bd7f /lib
parente4977b08d55b69e503379cdc2f98a5589e1152e1 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/html.source.sh18
1 files 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 () {