diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-16 17:11:44 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-16 17:11:44 +0300 |
| commit | 1309aff1606f7ec0f63b8b80a0b2d15d41697de9 (patch) | |
| tree | 60cc870890e05fe1b89379c849a30554015e68e4 /src/lib/bootstrap.source.sh | |
| parent | 68aadbbc3469d81f2adff8cb1d3052db4f75fe5b (diff) | |
un0 build template context file without declare -f or a bash subprocess
source_template_file previously built the BASH_ENV context file by piping
"declare -p ...; declare -f; serialize_template_render_context ...;" into a
fresh "bash -euo pipefail" subprocess for every rendered page. That dumped all
~5000 lines of shuriken functions and spawned a subprocess per page just to run
the serializer - a large per-page cost for albums with hundreds-to-thousands of
pages.
Now serialize_template_render_context runs in the current shell with stdout
redirected straight into the context tempfile, followed by an appended
"unset BASH_ENV". The serializer returns its own non-zero status explicitly so
the failure is detected via an "if" status-test (which returns normally through
the RETURN trap and cleans up the partial context file), robust even when
source_template_file runs inside a status-tested "if template ..." call chain
where bash would otherwise suppress an inner errexit abort.
The trap-based cleanup (RETURN plus INT/TERM/HUP re-raising to $BASHPID) is
preserved unchanged. Two serializer test mocks that relied on the removed
"| bash" errexit now return non-zero explicitly. Rendered HTML output is
unchanged; just test, just shellcheck, just check-generated and
git diff --check all pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/bootstrap.source.sh')
0 files changed, 0 insertions, 0 deletions
