Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13384 - main/trunk/bin
Date: Wed, 22 Apr 2009 18:28:50
Message-Id: E1LwhBg-0004OA-C1@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-04-22 18:28:47 +0000 (Wed, 22 Apr 2009)
3 New Revision: 13384
4
5 Modified:
6 main/trunk/bin/ebuild.sh
7 Log:
8 Use declare -F to check existence of function definitions, instead of
9 type -t, in order to avoid use of subshells.
10
11
12 Modified: main/trunk/bin/ebuild.sh
13 ===================================================================
14 --- main/trunk/bin/ebuild.sh 2009-04-21 07:15:33 UTC (rev 13383)
15 +++ main/trunk/bin/ebuild.sh 2009-04-22 18:28:47 UTC (rev 13384)
16 @@ -629,7 +629,7 @@
17 }
18
19 ebuild_phase() {
20 - [ "$(type -t ${1})" == "function" ] && qa_call ${1}
21 + declare -F "$1" >/dev/null && qa_call $1
22 }
23
24 ebuild_phase_with_hooks() {
25 @@ -1261,7 +1261,7 @@
26 if [[ -n ${!__export_funcs_var} ]] ; then
27 for x in ${!__export_funcs_var} ; do
28 debug-print "EXPORT_FUNCTIONS: $x -> ${ECLASS}_$x"
29 - [[ $(type -t ${ECLASS}_$x) = function ]] || \
30 + declare -F "${ECLASS}_$x" >/dev/null || \
31 die "EXPORT_FUNCTIONS: ${ECLASS}_$x is not defined"
32 eval "$x() { ${ECLASS}_$x \"\$@\" ; }" > /dev/null
33 done
34 @@ -1440,7 +1440,7 @@
35 local x y default_func=""
36
37 for x in pkg_nofetch src_unpack src_test ; do
38 - [[ $(type -t $x) = function ]] || \
39 + declare -F $x >/dev/null || \
40 eval "$x() { _eapi0_$x \"\$@\" ; }"
41 done
42
43 @@ -1448,7 +1448,7 @@
44
45 0|1)
46
47 - if [[ $(type -t src_compile) != function ]] ; then
48 + if ! declare -F src_compile >/dev/null ; then
49 case $eapi in
50 0)
51 src_compile() { _eapi0_src_compile "$@" ; }
52 @@ -1473,10 +1473,10 @@
53
54 *)
55
56 - [[ $(type -t src_configure) = function ]] || \
57 + declare -F src_configure >/dev/null || \
58 src_configure() { _eapi2_src_configure "$@" ; }
59
60 - [[ $(type -t src_compile) = function ]] || \
61 + declare -F src_compile >/dev/null || \
62 src_compile() { _eapi2_src_compile "$@" ; }
63
64 if hasq $phase_func $default_phases ; then
65 @@ -1838,7 +1838,7 @@
66 [[ -n $EAPI ]] || EAPI=0
67
68 # alphabetically ordered by $EBUILD_PHASE value
69 - local valid_phases
70 + local f valid_phases
71 case "$EAPI" in
72 0|1)
73 valid_phases="src_compile pkg_config pkg_info src_install
74 @@ -1854,7 +1854,7 @@
75
76 DEFINED_PHASES=
77 for f in $valid_phases ; do
78 - if [[ $(type -t $f) = function ]] ; then
79 + if declare -F $f >/dev/null ; then
80 f=${f#pkg_}
81 DEFINED_PHASES+=" ${f#src_}"
82 fi
83 @@ -1954,8 +1954,8 @@
84 exit 1
85 ;;
86 prerm|postrm|postinst|config|info)
87 - if hasq ${EBUILD_SH_ARGS} config info && \
88 - [ "$(type -t pkg_${EBUILD_SH_ARGS})" != "function" ]; then
89 + if hasq "$EBUILD_SH_ARGS" config info && \
90 + ! declare -F "pkg_$EBUILD_SH_ARGS" >/dev/null ; then
91 ewarn "pkg_${EBUILD_SH_ARGS}() is not defined: '${EBUILD##*/}'"
92 fi
93 export SANDBOX_ON="0"