From 19752b408d3d819343b9f31f12d17792fe91746c Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Tue, 26 Mar 2019 20:17:39 -0400 Subject: 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. --- libs/project | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'libs/project') 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 -# Copyright (C) 2018 Andrew Robbins +# Copyright (C) 2018,2019 Andrew Robbins # # 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() { -- cgit v1.2.3-70-g09d2