From 00c48574fe9598863a6bf5f59fcfca11fef64229 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 26 Mar 2026 18:42:41 -0400 Subject: [PATCH] refactor(run_path): avoid carrying return_code across iterations (#2552) Limit return_code to the per-script failure path instead of keeping it as loop state. This does not change current behavior, but makes the code easier to reason about and avoids future stale-state bugs if the loop logic is refactored. Signed-off-by: Josh --- docker-entrypoint.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 303aa005..c76b51ee 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -22,7 +22,6 @@ run_as() { # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" - local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" @@ -42,12 +41,11 @@ run_path() { echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) - run_as "${script_file_path}" || return_code="$?" - - if [ "${return_code}" -ne "0" ]; then + run_as "${script_file_path}" || { + return_code="$?" echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 - fi + } echo "==> Finished executing the script: \"${script_file_path}\"" done