aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorAndrew Robbins <contact@andrewrobbins.info>2019-04-26 23:16:20 -0400
committerAndrew Robbins <contact@andrewrobbins.info>2019-04-26 23:16:20 -0400
commit7ead9b132dd6f55c3268e479aa01dcdb8280bdf9 (patch)
tree3487f0554232e30bea0fb4d13e650d92eb757167 /libs
parent92a7d05d90c6c45648820bcea61e725f8c0d2893 (diff)
downloadlibrebootfr-7ead9b132dd6f55c3268e479aa01dcdb8280bdf9.tar.gz
librebootfr-7ead9b132dd6f55c3268e479aa01dcdb8280bdf9.zip
libs/project: Print project_action() footer, always
Previously, the footer would not print if the project action failed due to 'set -e' still being in effect (the subshell would return with a non-zero exit code and exit immediately). The purpose of the subshell for the project action is to better separate the execution environment of the project from the library functions it calls. The test condition in the if-statement and its consequents were changed in order to be more concise and informative.
Diffstat (limited to 'libs')
-rwxr-xr-xlibs/project25
1 files changed, 15 insertions, 10 deletions
diff --git a/libs/project b/libs/project
index 52888e32..e5088265 100755
--- a/libs/project
+++ b/libs/project
@@ -147,21 +147,26 @@ project_action() {
return 0
fi
- printf '%s\n\n' "Project $project $action (with ${arguments:-no argument})"
-
(
set +e
- "$action" "$@"
- )
+ printf '%s\n\n' "Project $project $action (with ${arguments:-no argument})"
- if [[ $? -eq 0 ]]; then
- printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) completed"
- else
- printf 1>&2 '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed"
+ (
+ "$action" "$@"
+ )
+
+ local -i exit_status=$?
+
+ if ((exit_status)); then
+ printf 1>&2 '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed"
+ else
+ printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) completed"
+ fi
+
+ exit $exit_status
+ )
- return 1
- fi
}
project_action_check() {