Hi,

I would like some clarification on what the bug in bash is that prevents us using [[ style tests when testing if a function exists. We have this in the two patches that change all the tests in makepkg:

* if [ $(type ... preserved due to a bash bug with [[ and set -e and ERR traps

I also have a patch from Cedric that makes the build() function optional which uses [[ for the "type -p" test.

Here is an example script based on code Cedric provided:

--start--
#!/bin/bash -e

set -E
trap 'echo >&2 "DANGER: ERRORS ABOUND!"' ERR

build() {
 echo "build"
}

[[ $(! type -t build) = "function" ]] && echo "yes" || echo "no"
[[ $(! type -t package) = "function" ]] && echo "yes" || echo "no"
--end--

That outputs "yes" for the build function and "no" for the package function without an error trap being triggered. I know the "!" is a workaround to stop the error trap being triggered, but is there something wrong with that?

Allan


Reply via email to