Skip to content

Commit f91002b

Browse files
committed
Abort execution on non-0 exit status from "after" scripts
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.
1 parent 59b5178 commit f91002b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

steps/improve/after.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22
#
33
# SPDX-FileCopyrightText: 2024 Gábor Stefanik <[email protected]>
4+
# SPDX-FileCopyrightText: 2025 Dor Askayo <[email protected]>
45
#
56
# SPDX-License-Identifier: GPL-3.0-or-later
67
#
@@ -10,7 +11,10 @@
1011
. /steps/env
1112

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

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

0 commit comments

Comments
 (0)