[pacman-dev] bash-3 only error trap activation

Andres P aepd87 at gmail.com
Mon Jun 21 13:42:17 EDT 2010

On Mon, Jun 21, 2010 at 1:06 AM, Allan McRae <allan at 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.


pmout=$(run_pacman -T "$@") || ret=$?

Using || after the asigment will prevent setting the err trap.

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.

Andres P

More information about the pacman-dev mailing list