1 |
commit: 50457583ba5c4242fbf9eedf35cd3e4f77c42ce6 |
2 |
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Mar 26 14:45:34 2012 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat May 26 10:40:50 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=50457583 |
7 |
|
8 |
Builtin: handle __export_funcs_var in inherit |
9 |
|
10 |
--- |
11 |
src/builtins/inherit_builtin.cpp | 19 ++++++++++++++++--- |
12 |
utils/isolated-functions.sh | 2 +- |
13 |
2 files changed, 17 insertions(+), 4 deletions(-) |
14 |
|
15 |
diff --git a/src/builtins/inherit_builtin.cpp b/src/builtins/inherit_builtin.cpp |
16 |
index 1490e5b..96dab9b 100644 |
17 |
--- a/src/builtins/inherit_builtin.cpp |
18 |
+++ b/src/builtins/inherit_builtin.cpp |
19 |
@@ -83,8 +83,8 @@ int inherit_builtin::exec(const std::vector<std::string>& bash_args) |
20 |
{ |
21 |
location = eclassdir + *iter + ".eclass"; |
22 |
_walker.set_value("ECLASS", *iter); |
23 |
- export_funcs_var = "__export_functions_" + _walker.resolve<std::string>("ECLASS_DEPTH"); |
24 |
- _walker.unset(export_funcs_var); |
25 |
+ _walker.define("__export_funcs_var", "__export_functions_" + _walker.resolve<std::string>("ECLASS_DEPTH")); |
26 |
+ _walker.unset(_walker.resolve<std::string>("__export_funcs_var")); |
27 |
|
28 |
// Portage implementation performs actions for overlays here but we don't do it for now |
29 |
|
30 |
@@ -108,7 +108,20 @@ int inherit_builtin::exec(const std::vector<std::string>& bash_args) |
31 |
restore_global("RDEPEND", B_RDEPEND); |
32 |
restore_global("PDEPEND", B_PDEPEND); |
33 |
|
34 |
- // Portage implementation exports functions here but we don't do it for now |
35 |
+ if(!_walker.is_unset(_walker.resolve<std::string>("__export_funcs_var"))) |
36 |
+ { |
37 |
+ std::stringstream func_names(_walker.resolve<std::string>(_walker.resolve<std::string>("__export_funcs_var"))); |
38 |
+ std::string func_name; |
39 |
+ |
40 |
+ while(func_names >> func_name) |
41 |
+ { |
42 |
+ std::stringstream func; |
43 |
+ func << func_name << "() { " << _walker.resolve<std::string>("ECLASS") << "_" << func_name |
44 |
+ << " \"$@\" ; }"; |
45 |
+ _walker.execute_builtin("eval", {func.str()}); |
46 |
+ } |
47 |
+ } |
48 |
+ _walker.unset(_walker.resolve<std::string>("__export_funcs_var")); |
49 |
|
50 |
if(!hasq(*iter, "INHERITED")) |
51 |
_walker.set_value("INHERITED", _walker.resolve<std::string>("INHERITED") + " " + *iter); |
52 |
|
53 |
diff --git a/utils/isolated-functions.sh b/utils/isolated-functions.sh |
54 |
index 9d189ed..150fe4b 100755 |
55 |
--- a/utils/isolated-functions.sh |
56 |
+++ b/utils/isolated-functions.sh |
57 |
@@ -19,7 +19,7 @@ EXPORT_FUNCTIONS() { |
58 |
die "EXPORT_FUNCTIONS without a defined ECLASS" |
59 |
return 1 |
60 |
fi |
61 |
- __export_funcs_var="$__export_funcs_var $*" |
62 |
+ eval $__export_funcs_var+=\" $*\" |
63 |
} |
64 |
|
65 |
use() { |