]> 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)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 25 Sep 2023 13:56:40 +0000 (10:56 -0300)
commitd9849aaa3aa777072c846526c772a896b5424cfb
tree71b39de03a2124b7a923b7bcfd3d421511c520e9
parent7ac91b24cfb49e094a1d13008bd0efda0b63e288
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>
debian/scripts/koha-foreach