From 6ba55bbc446f3c139668960c323ab3ff9ddaee0c Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Jun 2020 15:52:25 +1000 Subject: [PATCH] Bug 25634: Warn if koha-shell returns non-zero in koha-foreach By putting koha-shell in an if statement, "set -e" will no longer cause the entire koha-foreach program to exit, if koha-shell returns a non-zero status. If a non-zero status is returned, we warn on it, and the caller of koha-foreach can interpret that command visually. To Test: 1) Write a shell script that says "Hello" and then exits with a 1 status 2) Run koha-foreach against that shell script with multiple instances available to koha-foreach 3) Before the patch, koha-foreach will die after the first "Hello" 4) After the patch, koha-foreach will continue, through all the instances, and report which instances returned non-zero statuses by which command. --- debian/scripts/koha-foreach | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/scripts/koha-foreach b/debian/scripts/koha-foreach index 9682f14b85..735bc49748 100755 --- a/debian/scripts/koha-foreach +++ b/debian/scripts/koha-foreach @@ -61,7 +61,9 @@ do # Change to the instance's home dir if required [ "$chdir" != "no" ] && eval cd ~$name"-koha" - koha-shell ${name} -c "${cmd}" + if ! koha-shell ${name} -c "${cmd}"; then + echo "${name}: non-zero status returned by \"${cmd}\"" + fi # Go back to the original dir if required [ "$chdir" != "no" ] && cd "$starting_dir" -- 2.16.4