On 22/06/10 03:42, Andres P wrote:
On Mon, Jun 21, 2010 at 1:06 AM, Allan McRae<allan@archlinux.org> wrote:
pmout=$(run_pacman -T "$@")<- HERE ret=$?
The first one gets set off anytime "depends" or "makedepends" are empty and can be fixed by using "|| return 0", but the second is doing my head in... Of course, turning off the error trap around those commands makes it work, and that may be an OK approach given we are dealing with all error states below that.
Try:
ret=$? pmout=$(run_pacman -T "$@") || ret=$?
Using || after the asigment will prevent setting the err trap.
Of course I tried that... It does not work: ==> Making package: pacman-contrib 3.4.0-1 (Tue Jun 22 08:46:58 EST 2010) ==> Checking Runtime Dependencies... ==> 127 ($ret value from within run_pacman) ==> ERROR: An unknown error has occurred. Exiting... ==> 1 ($ret value after "|| ret=$?") ==> ERROR: 'pacman' returned a fatal error (1): pacman>4 (wrong return value so wrong error message) I looks like in bash-3.2 the following happens. run_pacman returns 127 which sets off the error trap. Then the assignment fails which sets of another error trap. The use of "|| ret=$?" prevents the assignment failure error but now there is the wrong return value.
Funny how you noticed the first, because I was about to submit a patch that did not return false if there were no arguments.
In reality though, it should be this: [[ $@ ]] || return 0
Because (( $# )) will not count emtpy arguments.
If check_deps is passed quoted arguments that expand to nothing, it will malfunction.
I think that if check_deps is passed empty arguments, then there is not dependencies to check and it should just return. Allan