[pacman-dev] type -p tests in makepkg
allan at archlinux.org
Mon Nov 16 05:30:07 EST 2009
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
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:
trap 'echo >&2 "DANGER: ERRORS ABOUND!"' ERR
[[ $(! type -t build) = "function" ]] && echo "yes" || echo "no"
[[ $(! type -t package) = "function" ]] && echo "yes" || echo "no"
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?
More information about the pacman-dev