aboutsummaryrefslogtreecommitdiff
path: root/libs/project
diff options
context:
space:
mode:
authorAndrew Robbins <contact@andrewrobbins.info>2019-03-26 20:17:39 -0400
committerAndrew Robbins <contact@andrewrobbins.info>2019-03-26 22:34:32 -0400
commit19752b408d3d819343b9f31f12d17792fe91746c (patch)
tree00649a7a03acd574d18f5a29d89ea3a3d4b1e02b /libs/project
parent335da90531ea47d4f4a7c515503978f7af456439 (diff)
downloadlibrebootfr-19752b408d3d819343b9f31f12d17792fe91746c.tar.gz
librebootfr-19752b408d3d819343b9f31f12d17792fe91746c.zip
libs/project: Execute project action in subshell
Executing the project action within its own subshell makes it easy to abort the action with a simple "exit" while still allowing for the printing of the footer describing failure/success. Prevously, if "exit" were called in a project action the footer would not print.
Diffstat (limited to 'libs/project')
-rwxr-xr-xlibs/project22
1 files changed, 9 insertions, 13 deletions
diff --git a/libs/project b/libs/project
index 70a76d71..6fae6fa0 100755
--- a/libs/project
+++ b/libs/project
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
-# Copyright (C) 2018 Andrew Robbins <contact@andrewrobbins.info>
+# Copyright (C) 2018,2019 Andrew Robbins <contact@andrewrobbins.info>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -147,21 +147,17 @@ project_action() {
shift
local arguments="$*"
- (
- set +e
-
- project_action_check "$action" "$project" "$@"
+ project_action_check "$action" "$project" "$@"
- printf '%s\n\n' "Project $project $action (with ${arguments:-no argument})"
+ printf '%s\n\n' "Project $project $action (with ${arguments:-no argument})"
- if "$action" "$@"; 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"
+ if (set +e; "$action" "$@"); 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"
- return 1
- fi
- )
+ return 1
+ fi
}
project_action_check() {