[Koha-bugs] [Bug 34653] Make koha-foreach return the correct status code

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Sep 6 01:54:27 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34653

David Cook <dcook at prosentient.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|Needs Signoff               |In Discussion

--- Comment #3 from David Cook <dcook at prosentient.com.au> ---
The test for this one is a bit too simplistic, and it misses some steps.

For instance, after "Apply patch", you need to either copy
debian/scripts/koha-foreach to /usr/sbin/koha-foreach, or run the command from
"debian/scripts/koha-foreach".

As for the simplicity, I've created an alternative test:

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

root at kohadevbox:koha(bug_34653)$ debian/scripts/koha-foreach sh test.sh
FAILED
kohadev: 1 status returned by "sh test.sh"
SUCCESS
root at kohadevbox:koha(bug_34653)$ echo $?
1

--

With this patch, the exit code will be whatever the last non-zero exit code was
in the koha-foreach loop. I'm not sure that's really what we want. 

I think it might be better if we exit with "1" if any command has a non-zero
exit code. 

To do that, we could keep the current patch for the most part, or we could
increment an error counter, or something else.

Because we're running in a loop and apparently koha-foreach doesn't ditch out
on  non-zero exit code, I don't think we should just return the last $rv
encountered.

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list