summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/action.source.sh91
-rwxr-xr-xsrc/shuriken.sh2
2 files changed, 12 insertions, 81 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() {
diff --git a/src/shuriken.sh b/src/shuriken.sh
index 4114806..75f79cb 100755
--- a/src/shuriken.sh
+++ b/src/shuriken.sh
@@ -149,7 +149,7 @@ main() {
return "$status"
fi
- SHURIKEN_ACTION_BODY_RUNNER=run_action_body_direct run_action
+ run_action
status=$?
if (( status != 0 )); then
return "$status"