From 1309aff1606f7ec0f63b8b80a0b2d15d41697de9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 16 Jun 2026 17:11:44 +0300 Subject: 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 --- tests/cli.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/cli.sh b/tests/cli.sh index 1dac04a..8727532 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -4433,8 +4433,12 @@ SHURIKEN_FAKE_CONTEXT_FILE="$context_file" export SHURIKEN_FAKE_CONTEXT_FILE serialize_template_render_context() { - false + # Simulate a serializer that writes some output and then fails. The new + # implementation propagates this non-zero status explicitly (it no longer + # relies on a "| bash -euo pipefail" subprocess), so source_template_file + # must detect the failure, skip the render and clean up the context file. printf 'partial_context=yes\n' + return 1 } # shellcheck disable=SC2034 @@ -4518,8 +4522,12 @@ SHURIKEN_OUTPUT_MODE=quiet apply_config_defaults serialize_template_render_context() { - false + # Simulate a serializer that writes some output and then fails. The new + # implementation propagates this non-zero status explicitly (it no longer + # relies on a "| bash -euo pipefail" subprocess), so source_template_file + # must detect the failure, skip the render and clean up the context file. printf 'partial_context=yes\n' + return 1 } if template preview out.html \ -- cgit v1.2.3