summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-04-22 18:28:47 +0000
committerZac Medico <zmedico@gentoo.org>2009-04-22 18:28:47 +0000
commit9a3788e95fb0a03fbaf1305fe94a32b11265641e (patch)
treeb323dda89a60afb6a9a79def5b3c0d7e5a489231
parent9d0376223484887e6aa5ca1180568f9cb83249e9 (diff)
downloadportage-9a3788e95fb0a03fbaf1305fe94a32b11265641e.tar.gz
portage-9a3788e95fb0a03fbaf1305fe94a32b11265641e.tar.bz2
portage-9a3788e95fb0a03fbaf1305fe94a32b11265641e.zip
Use declare -F to check existence of function definitions, instead of
type -t, in order to avoid use of subshells. svn path=/main/trunk/; revision=13384
-rwxr-xr-xbin/ebuild.sh20
1 files changed, 10 insertions, 10 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index c9d9b786f..57f1a9e60 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -629,7 +629,7 @@ _eapi2_src_compile() {
}
ebuild_phase() {
- [ "$(type -t ${1})" == "function" ] && qa_call ${1}
+ declare -F "$1" >/dev/null && qa_call $1
}
ebuild_phase_with_hooks() {
@@ -1261,7 +1261,7 @@ inherit() {
if [[ -n ${!__export_funcs_var} ]] ; then
for x in ${!__export_funcs_var} ; do
debug-print "EXPORT_FUNCTIONS: $x -> ${ECLASS}_$x"
- [[ $(type -t ${ECLASS}_$x) = function ]] || \
+ declare -F "${ECLASS}_$x" >/dev/null || \
die "EXPORT_FUNCTIONS: ${ECLASS}_$x is not defined"
eval "$x() { ${ECLASS}_$x \"\$@\" ; }" > /dev/null
done
@@ -1440,7 +1440,7 @@ _ebuild_phase_funcs() {
local x y default_func=""
for x in pkg_nofetch src_unpack src_test ; do
- [[ $(type -t $x) = function ]] || \
+ declare -F $x >/dev/null || \
eval "$x() { _eapi0_$x \"\$@\" ; }"
done
@@ -1448,7 +1448,7 @@ _ebuild_phase_funcs() {
0|1)
- if [[ $(type -t src_compile) != function ]] ; then
+ if ! declare -F src_compile >/dev/null ; then
case $eapi in
0)
src_compile() { _eapi0_src_compile "$@" ; }
@@ -1473,10 +1473,10 @@ _ebuild_phase_funcs() {
*)
- [[ $(type -t src_configure) = function ]] || \
+ declare -F src_configure >/dev/null || \
src_configure() { _eapi2_src_configure "$@" ; }
- [[ $(type -t src_compile) = function ]] || \
+ declare -F src_compile >/dev/null || \
src_compile() { _eapi2_src_compile "$@" ; }
if hasq $phase_func $default_phases ; then
@@ -1838,7 +1838,7 @@ _source_ebuild() {
[[ -n $EAPI ]] || EAPI=0
# alphabetically ordered by $EBUILD_PHASE value
- local valid_phases
+ local f valid_phases
case "$EAPI" in
0|1)
valid_phases="src_compile pkg_config pkg_info src_install
@@ -1854,7 +1854,7 @@ _source_ebuild() {
DEFINED_PHASES=
for f in $valid_phases ; do
- if [[ $(type -t $f) = function ]] ; then
+ if declare -F $f >/dev/null ; then
f=${f#pkg_}
DEFINED_PHASES+=" ${f#src_}"
fi
@@ -1954,8 +1954,8 @@ ebuild_main() {
exit 1
;;
prerm|postrm|postinst|config|info)
- if hasq ${EBUILD_SH_ARGS} config info && \
- [ "$(type -t pkg_${EBUILD_SH_ARGS})" != "function" ]; then
+ if hasq "$EBUILD_SH_ARGS" config info && \
+ ! declare -F "pkg_$EBUILD_SH_ARGS" >/dev/null ; then
ewarn "pkg_${EBUILD_SH_ARGS}() is not defined: '${EBUILD##*/}'"
fi
export SANDBOX_ON="0"