Bug 33645 - koha-foreach always returns 1 if --chdir not specified
Summary: koha-foreach always returns 1 if --chdir not specified
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-02 00:15 UTC by David Cook
Modified: 2023-12-28 20:47 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.06,22.05.14,21.11.22


Attachments
Bug 33645: Make koha-foreach return 0 if it completes successfully (931 bytes, patch)
2023-05-02 00:19 UTC, David Cook
Details | Diff | Splinter Review
Bug 33645: Make koha-foreach return 0 if it completes successfully (980 bytes, patch)
2023-05-02 01:45 UTC, David Nind
Details | Diff | Splinter Review
Bug 33645: Make koha-foreach return 0 if it completes successfully (1.03 KB, patch)
2023-05-03 07:34 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2023-05-02 00:15:45 UTC
If you don't provide --chdir to koha-foreach it will always return an exit code of 1, because the final if statement in the script will return false
Comment 1 David Cook 2023-05-02 00:19:16 UTC
Created attachment 150484 [details] [review]
Bug 33645: Make koha-foreach return 0 if it completes successfully

This patch adds an "exit 0" to the end of koha-foreach, so that it
returns a successful exit code if it reaches the bottom of the script
without errors.

Test plan:
0) `koha-foreach echo`
1) `echo $?`
2) Note that the exit status is 1
3) Apply patch
4) `./debian/scripts/koha-foreach echo`
5) `echo $?`
6) Note that the exit status is 0
Comment 2 David Nind 2023-05-02 01:45:31 UTC
Created attachment 150492 [details] [review]
Bug 33645: Make koha-foreach return 0 if it completes successfully

This patch adds an "exit 0" to the end of koha-foreach, so that it
returns a successful exit code if it reaches the bottom of the script
without errors.

Test plan:
0) `koha-foreach echo`
1) `echo $?`
2) Note that the exit status is 1
3) Apply patch
4) `./debian/scripts/koha-foreach echo`
5) `echo $?`
6) Note that the exit status is 0

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Jonathan Druart 2023-05-03 07:34:40 UTC
Created attachment 150566 [details] [review]
Bug 33645: Make koha-foreach return 0 if it completes successfully

This patch adds an "exit 0" to the end of koha-foreach, so that it
returns a successful exit code if it reaches the bottom of the script
without errors.

Test plan:
0) `koha-foreach echo`
1) `echo $?`
2) Note that the exit status is 1
3) Apply patch
4) `./debian/scripts/koha-foreach echo`
5) `echo $?`
6) Note that the exit status is 0

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Tomás Cohen Arazi 2023-05-05 18:43:25 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 5 Martin Renvoize 2023-05-12 15:24:09 UTC
Many hands makes light work, thankyou everyone!

Pushed to 22.11.x for the next release
Comment 6 Lucas Gass 2023-06-13 16:30:14 UTC
Backported to 22.05.x for upcoming 22.05.14
Comment 7 Danyon Sewell 2023-07-21 02:48:10 UTC
Backported to 21.11.x for upcoming 21.11.22.