]> git.koha-community.org Git - koha.git/commit
Bug 34653: Make koha-foreach return the correct status code
authorEvan Giles <evan@catalyst.net.nz>
Fri, 1 Sep 2023 06:42:45 +0000 (18:42 +1200)
committerFridolin Somers <fridolin.somers@biblibre.com>
Mon, 25 Sep 2023 19:28:42 +0000 (09:28 -1000)
commit392edc1a2fe1f84f94b03bd569a10adb60dbc6fe
treea411025aa7b393fb343773d3d7e9c56a051c56e8
parent6dbd5e5fdbe333b0f0e7197e729ffe659ff98cf1
Bug 34653: Make koha-foreach return the correct status code

I think the correct behavior for this script should be that koha-foreach
will return 0 (success) if all the commands it tried to run succeeded, but
1 (failure) if any of the commands failed.

To test:
1. $ koha-create --create-db test
2. $ vi test.sh
if [ $USER = 'kohadev-koha' ]; then
    echo "FAILED";
    exit 1;
else
    echo "SUCCESS";
    exit 0;
fi

3. $ debian/scripts/koha-foreach sh test.sh
FAILED
kohadev: 1 status returned by "sh test.sh"
SUCCESS
4. $ echo $?
5. Note that the exit status is 0 (success)

6. Apply patch

7. $ debian/scripts/koha-foreach sh test.sh
FAILED
kohadev: 1 status returned by "sh test.sh"
SUCCESS
8. $ echo $?
9. Note that the exit status is 1 (failure)

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit d9849aaa3aa777072c846526c772a896b5424cfb)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
debian/scripts/koha-foreach