summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-12 15:15:38 +0300
committerPaul Buetow <paul@buetow.org>2026-06-12 15:15:38 +0300
commit81a3be6379198c697de2f8639dcaa1cdc9d66a53 (patch)
tree603b8f4f51b025f268664008b2b208a292324c68
parent6aa19aa81090898c942f44677867b1abcdb06589 (diff)
Fix remaining errexit masking for bm0
-rwxr-xr-xbin/shuriken67
-rw-r--r--src/lib/action.source.sh2
-rw-r--r--src/lib/album.source.sh44
-rw-r--r--src/lib/template.source.sh21
-rwxr-xr-xtests/cli.sh35
5 files changed, 138 insertions, 31 deletions
diff --git a/bin/shuriken b/bin/shuriken
index 58fa2ac..d3db424 100755
--- a/bin/shuriken
+++ b/bin/shuriken
@@ -741,6 +741,7 @@ source_template_file() {
local -r output_path="$1"; shift
local -r render_vars_name="$1"; shift
local context_file
+ local restore_errexit=no
local -i status=0
context_file=$(mktemp)
@@ -749,14 +750,20 @@ source_template_file() {
return "$status"
fi
- if {
- serialize_template_render_context "$render_vars_name" \
- &&
+ if [[ "$-" == *e* ]]; then
+ restore_errexit=yes
+ set +e
+ fi
+ (
+ set -e
+ serialize_template_render_context "$render_vars_name"
printf 'unset BASH_ENV\n'
- } > "$context_file"; then
- status=0
- else
- status=$?
+ ) > "$context_file"
+ status=$?
+ if [ "$restore_errexit" = yes ]; then
+ set -e
+ fi
+ if (( status != 0 )); then
rm -f "$context_file"
return "$status"
fi
@@ -2282,21 +2289,51 @@ generate() {
}
refresh_splash() {
+ local restore_errexit=no
+ local -i status=0
local tmp_html
local tmp_path
tmp_path=$(mktemp "$DIST_DIR/.index.html.XXXXXX")
tmp_html=$(basename "$tmp_path")
- if render_album_splash_page 'photos' '.' 'blurs' '.' "$tmp_html" \
- && prepare_generation_site_assets; then
- mv "$DIST_DIR/$tmp_html" "$DIST_DIR/index.html"
- log_info "Refreshed splash page $(_display_path "$DIST_DIR/index.html")"
- return
+ if [[ "$-" == *e* ]]; then
+ restore_errexit=yes
+ set +e
+ fi
+ (
+ set -e
+ render_album_splash_page 'photos' '.' 'blurs' '.' "$tmp_html"
+ )
+ status=$?
+ if [ "$restore_errexit" = yes ]; then
+ set -e
+ fi
+ if (( status != 0 )); then
+ rm -f "$DIST_DIR/$tmp_html"
+ return "$status"
fi
- rm -f "$DIST_DIR/$tmp_html"
- return 1
+ restore_errexit=no
+ if [[ "$-" == *e* ]]; then
+ restore_errexit=yes
+ set +e
+ fi
+ (
+ set -e
+ prepare_generation_site_assets
+ )
+ status=$?
+ if [ "$restore_errexit" = yes ]; then
+ set -e
+ fi
+ if (( status != 0 )); then
+ rm -f "$DIST_DIR/$tmp_html"
+ return "$status"
+ fi
+
+ mv "$DIST_DIR/$tmp_html" "$DIST_DIR/index.html"
+ log_info "Refreshed splash page $(_display_path "$DIST_DIR/index.html")"
}
dry_run() {
@@ -3135,7 +3172,7 @@ run_action_body() {
if [[ "$-" == *e* ]]; then
"$@"
else
- ( "$@" )
+ ( set -e; "$@" )
fi
}
diff --git a/src/lib/action.source.sh b/src/lib/action.source.sh
index aba24a8..f3e92be 100644
--- a/src/lib/action.source.sh
+++ b/src/lib/action.source.sh
@@ -27,7 +27,7 @@ run_action_body() {
if [[ "$-" == *e* ]]; then
"$@"
else
- ( "$@" )
+ ( set -e; "$@" )
fi
}
diff --git a/src/lib/album.source.sh b/src/lib/album.source.sh
index 29eff6b..b5495f5 100644
--- a/src/lib/album.source.sh
+++ b/src/lib/album.source.sh
@@ -943,21 +943,51 @@ generate() {
}
refresh_splash() {
+ local restore_errexit=no
+ local -i status=0
local tmp_html
local tmp_path
tmp_path=$(mktemp "$DIST_DIR/.index.html.XXXXXX")
tmp_html=$(basename "$tmp_path")
- if render_album_splash_page 'photos' '.' 'blurs' '.' "$tmp_html" \
- && prepare_generation_site_assets; then
- mv "$DIST_DIR/$tmp_html" "$DIST_DIR/index.html"
- log_info "Refreshed splash page $(_display_path "$DIST_DIR/index.html")"
- return
+ if [[ "$-" == *e* ]]; then
+ restore_errexit=yes
+ set +e
+ fi
+ (
+ set -e
+ render_album_splash_page 'photos' '.' 'blurs' '.' "$tmp_html"
+ )
+ status=$?
+ if [ "$restore_errexit" = yes ]; then
+ set -e
+ fi
+ if (( status != 0 )); then
+ rm -f "$DIST_DIR/$tmp_html"
+ return "$status"
+ fi
+
+ restore_errexit=no
+ if [[ "$-" == *e* ]]; then
+ restore_errexit=yes
+ set +e
+ fi
+ (
+ set -e
+ prepare_generation_site_assets
+ )
+ status=$?
+ if [ "$restore_errexit" = yes ]; then
+ set -e
+ fi
+ if (( status != 0 )); then
+ rm -f "$DIST_DIR/$tmp_html"
+ return "$status"
fi
- rm -f "$DIST_DIR/$tmp_html"
- return 1
+ mv "$DIST_DIR/$tmp_html" "$DIST_DIR/index.html"
+ log_info "Refreshed splash page $(_display_path "$DIST_DIR/index.html")"
}
dry_run() {
diff --git a/src/lib/template.source.sh b/src/lib/template.source.sh
index 58cdfa8..8ab87b2 100644
--- a/src/lib/template.source.sh
+++ b/src/lib/template.source.sh
@@ -296,6 +296,7 @@ source_template_file() {
local -r output_path="$1"; shift
local -r render_vars_name="$1"; shift
local context_file
+ local restore_errexit=no
local -i status=0
context_file=$(mktemp)
@@ -304,14 +305,20 @@ source_template_file() {
return "$status"
fi
- if {
- serialize_template_render_context "$render_vars_name" \
- &&
+ if [[ "$-" == *e* ]]; then
+ restore_errexit=yes
+ set +e
+ fi
+ (
+ set -e
+ serialize_template_render_context "$render_vars_name"
printf 'unset BASH_ENV\n'
- } > "$context_file"; then
- status=0
- else
- status=$?
+ ) > "$context_file"
+ status=$?
+ if [ "$restore_errexit" = yes ]; then
+ set -e
+ fi
+ if (( status != 0 )); then
rm -f "$context_file"
return "$status"
fi
diff --git a/tests/cli.sh b/tests/cli.sh
index 0f6470f..c747594 100755
--- a/tests/cli.sh
+++ b/tests/cli.sh
@@ -2113,6 +2113,7 @@ SHURIKEN_CLI_OVERRIDES=()
SHURIKEN_CLI_SYNC_DESTINATIONS=()
SHURIKEN_FORCE_GENERATE=no
+set +e
run_configured_action
BASH
)
@@ -2835,6 +2836,35 @@ test_refresh_splash_requires_existing_generated_blurs() {
test::teardown
}
+test_refresh_splash_requires_matching_splash_photo() {
+ local config_file
+ local output
+
+ test::setup
+ config_file="$TEST_TMPDIR/shuriken.conf"
+ mkdir -p \
+ "$TEST_TMPDIR/incoming" \
+ "$TEST_TMPDIR/dist/photos" \
+ "$TEST_TMPDIR/dist/blurs"
+ printf 'old index\n' > "$TEST_TMPDIR/dist/index.html"
+ printf 'orphan photo\n' > "$TEST_TMPDIR/dist/photos/orphan.jpg"
+ test::write_album_config \
+ "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \
+ 'Missing matching splash photo album' 40
+
+ output=$(
+ cd "$TEST_TMPDIR"
+ test::capture_failure_output "$TEST_SHURIKEN" --refresh-splash
+ )
+
+ test::assert_contains \
+ "ERROR: No splash photos found in $TEST_TMPDIR/dist/photos" \
+ "$output"
+ test "$(<"$TEST_TMPDIR/dist/index.html")" = 'old index'
+ test::assert_find_count 0 "$TEST_TMPDIR/dist" '.index.html.*'
+ test::teardown
+}
+
test_refresh_splash_rejects_no_splash_config() {
local config_file
local output
@@ -3604,8 +3634,8 @@ SHURIKEN_FAKE_CONTEXT_FILE="$context_file"
export SHURIKEN_FAKE_CONTEXT_FILE
serialize_template_render_context() {
+ false
printf 'partial_context=yes\n'
- return 42
}
# shellcheck disable=SC2034
@@ -4494,6 +4524,9 @@ main() {
'--refresh-splash requires existing generated blurs' \
test_refresh_splash_requires_existing_generated_blurs
test::run_case \
+ '--refresh-splash requires matching splash photo' \
+ test_refresh_splash_requires_matching_splash_photo
+ test::run_case \
'--refresh-splash rejects SPLASH_PAGE=no' \
test_refresh_splash_rejects_no_splash_config
test::run_case \