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