Skip to content

Commit

Permalink
Abort execution on non-0 exit status from "after" scripts
Browse files Browse the repository at this point in the history
Failures in "after" scripts do not currently result in bootstrap
failures since "find" ignores the exit code of commands that it
executes.

There are no simple options in "find" to both propagate non-0 exit
statuses of executed commands and also abort its command execution
sequence in such an event. As such, use "find" only for listing
script names and otherwise use a simple loop to execute them.

While at it, execute scripts in numerical order according to their
basename. This gives consumers control over the execution order of
their scripts. For example, 50-sign.sh will be executed before
51-upload.sh.
  • Loading branch information
doraskayo committed Feb 26, 2025
1 parent 59b5178 commit f91002b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion steps/improve/after.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2024 Gábor Stefanik <[email protected]>
# SPDX-FileCopyrightText: 2025 Dor Askayo <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
Expand All @@ -10,7 +11,10 @@
. /steps/env

if [ -d /steps/after ]; then
find /steps/after -maxdepth 1 -name '*.sh' -exec bash {} \;
after_scripts=$(find /steps/after -maxdepth 1 -type f -name '*.sh' -printf '%f\t%p\n' | sort -k1 -n | cut -f2)
for script in $after_scripts; do
bash "$script"
done
fi

if [ "${INTERACTIVE}" = True ]; then
Expand Down

0 comments on commit f91002b

Please sign in to comment.