]> 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)
committerJacob O'Mara <jacob.omara@ptfs-europe.com>
Tue, 17 Oct 2023 11:36:00 +0000 (12:36 +0100)
commit8bcd2d54bf092d4348c721751da362e51fb56618
tree8297c58daf24490e42597de57b8df5f2fa1d81fd
parent05a4e15398a30ca2268b18671968908e6c688637
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>
(cherry picked from commit 392edc1a2fe1f84f94b03bd569a10adb60dbc6fe)
Signed-off-by: Jacob O'Mara <jacob.omara@ptfs-europe.com>
debian/scripts/koha-foreach