summaryrefslogtreecommitdiff
path: root/src/lib/action.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-17 21:24:45 +0300
committerPaul Buetow <paul@buetow.org>2026-06-17 21:24:45 +0300
commit6109e2a6f5bc45c3c4080259bd09a1e3dc48ea4d (patch)
treedd862d7319be1c6a8b8ac24d15cd3518bd192c4e /src/lib/action.source.sh
parent5ebee8ef2a54b8578daf47b17fa82fc85b2cd1cd (diff)
on0 remove run_action_body serialization runner
Shuriken is a single-process CLI, yet the action layer could serialize 30+ globals plus every function definition (declare -p / declare -f) and pipe them into a fresh "bash -euo pipefail" process to run an action. Production already forced the in-process run_action_body_direct via SHURIKEN_ACTION_BODY_RUNNER, so the serialized-subprocess path was dead in production and only added complexity (a hand-maintained variable list to keep in sync). Per KISS, drop it. - Remove run_action_body_context and the run_action_body dispatcher. - Collapse run_configured_action_body to call the action in-process directly and remove the SHURIKEN_ACTION_BODY_RUNNER indirection in main(). - Move the only genuinely needed isolation into a test-only shim (test::run_action_isolated in tests/helpers.sh) for the generate real-failure test, which must capture a failure status without the in-process errexit abort ending the caller (correct in production, where main runs under errexit). - Update the errexit/status-propagation tests to exercise the direct path. Template-engine serialization is unrelated and left untouched. 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/action.source.sh')
-rw-r--r--src/lib/action.source.sh91
1 files changed, 11 insertions, 80 deletions
diff --git a/src/lib/action.source.sh b/src/lib/action.source.sh
index edececa..425e009 100644
--- a/src/lib/action.source.sh
+++ b/src/lib/action.source.sh
@@ -23,89 +23,20 @@ run_simple_action() {
esac
}
-run_action_body_context() {
- local name
- local -a variable_names=(
- VERSION
- DEFAULTRC
- PACKAGED_TEMPLATE_DIR
- PACKAGED_ASSET_DIR
- DEFAULT_TEMPLATE_DIR
- DEFAULT_ASSET_DIR
- SHURIKEN_SOURCE_DIR
- SHURIKEN_OUTPUT_MODE
- SHURIKEN_ACTIVE_GENERATION_PID
- SHURIKEN_FORCE_GENERATE
- SHURIKEN_CURRENT_DATE_TEXT
- SHURIKEN_CONFIG_SOURCE
- SHURIKEN_FINAL_DIST_DIR
- INCOMING_DIR
- DIST_DIR
- TEMPLATE_DIR
- FAVICON
- TITLE
- HEIGHT
- THUMBHEIGHT
- MAXPREVIEWS
- IMAGE_JOBS
- IMAGEMAGICK_TIMEOUT
- TAR_TIMEOUT
- ORIGINAL_BASEPATH
- RANDOM_SEED
- SHUFFLE
- SPLASH_PAGE
- STATS_PAGE
- TARBALL_INCLUDE
- TARBALL_SUFFIX
- TAR_OPTS
- SYNC_DELETE
- SYNC_DESTINATIONS
- TEMPLATE_RENDER_FIELD_SPECS
- )
-
- for name in "${variable_names[@]}"; do
- declare -p "$name" 2>/dev/null || true
- done
- declare -f
-}
-
-run_action_body() {
- local -r action_name="$1"; shift
- local -i status=0
-
- if {
- run_action_body_context
- printf '%q "$@"\n' "$action_name"
- } | bash -euo pipefail -s -- "$@"; then
- status=0
- else
- status=$?
- fi
-
- return "$status"
-}
-
-run_action_body_direct() {
- "$@"
-}
-
+# Runs an action function in-process and propagates its exit status.
+#
+# Shuriken is a single-process CLI, so the action body runs as a plain function
+# call in the current shell. An earlier version could serialize 30+ globals plus
+# every function definition and pipe them into a fresh "bash -euo pipefail"
+# subprocess for isolation. That added real complexity (a hand-maintained list
+# of variables to forward) for no benefit here: there is no second process to
+# isolate from and nothing the action needs protecting from. Per KISS we dropped
+# the subprocess runner and call the action directly. Tests that genuinely need
+# subprocess isolation provide their own shim in tests/helpers.sh.
run_configured_action_body() {
local -r action_name="$1"; shift
- local -r runner="${SHURIKEN_ACTION_BODY_RUNNER:-run_action_body}"
- local -i status=0
-
- if [ "$runner" = run_action_body_direct ]; then
- "$runner" "$action_name" "$@"
- return
- fi
-
- if "$runner" "$action_name" "$@"; then
- status=0
- else
- status=$?
- fi
- return "$status"
+ "$action_name" "$@"
}
load_configured_action() {