1 |
commit: ce9c217021e2154a64f8ed3b3e7c492bc8a4c917 |
2 |
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu> |
3 |
AuthorDate: Sat May 7 12:23:34 2011 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat May 7 12:23:34 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=ce9c2170 |
7 |
|
8 |
Merge remote-tracking branch 'mu/local_variables' |
9 |
|
10 |
Conflicts: |
11 |
scripts/function_def.bash |
12 |
|
13 |
|
14 |
bashast/bashast.g | 5 ++- |
15 |
bashast/gunit/simp_command.gunit | 1 + |
16 |
bashast/libbashWalker.g | 20 ++++++++++++++---- |
17 |
scripts/function_def.bash | 10 +++++++++ |
18 |
scripts/function_def.bash.result | 1 + |
19 |
src/core/interpreter.cpp | 40 +++++++++++++++++++++++++++++++++---- |
20 |
src/core/interpreter.h | 39 +++++++++++++++++++++--------------- |
21 |
7 files changed, 88 insertions(+), 28 deletions(-) |
22 |
|
23 |
diff --cc bashast/libbashWalker.g |
24 |
index beabfdf,1a305ef..f39e603 |
25 |
--- a/bashast/libbashWalker.g |
26 |
+++ b/bashast/libbashWalker.g |
27 |
@@@ -283,21 -292,13 +293,21 @@@ simple_comman |
28 |
@declarations { |
29 |
std::vector<std::string> libbash_args; |
30 |
} |
31 |
- :^(COMMAND string_expr (argument[libbash_args])* var_def*) { |
32 |
+ :^(COMMAND string_expr (argument[libbash_args])* var_def[true]*) { |
33 |
if(walker->has_function($string_expr.libbash_value)) |
34 |
{ |
35 |
- walker->set_status(walker->call($string_expr.libbash_value, |
36 |
- libbash_args, |
37 |
- ctx, |
38 |
- compound_command)); |
39 |
+ ANTLR3_MARKER command_index = INDEX(); |
40 |
+ try |
41 |
+ { |
42 |
+ walker->set_status(walker->call($string_expr.libbash_value, |
43 |
+ libbash_args, |
44 |
+ ctx, |
45 |
+ compound_command)); |
46 |
+ } |
47 |
+ catch(return_exception& e) |
48 |
+ { |
49 |
+ SEEK(command_index); |
50 |
+ } |
51 |
} |
52 |
else if(cppbash_builtin::is_builtin($string_expr.libbash_value)) |
53 |
{ |
54 |
diff --cc scripts/function_def.bash |
55 |
index ee57a94,cbce4cd..bcf5a4b |
56 |
--- a/scripts/function_def.bash |
57 |
+++ b/scripts/function_def.bash |
58 |
@@@ -27,18 -27,12 +27,28 @@@ ARRAY=(1 2 3 |
59 |
func_with_args ${ARRAY[@]} $FOO001 |
60 |
func_with_args 100 $ARG2 $ARG3 $ARG4 |
61 |
|
62 |
+func_with_return() |
63 |
+{ |
64 |
+ return 1 |
65 |
+ NOT_EXIST=1 |
66 |
+} |
67 |
+func_with_return |
68 |
+RETURN_STATUS=$? |
69 |
+func_with_return2() |
70 |
+{ |
71 |
+ true |
72 |
+ return |
73 |
+ NOT_EXIST=1 |
74 |
+} |
75 |
+func_with_return2 |
76 |
+RETURN_STATUS2=$? |
77 |
++ |
78 |
+ func_nested1() { |
79 |
+ echo $foo_nested ${bar_nested[0]} |
80 |
+ } |
81 |
+ func_nested2() { |
82 |
+ local foo_nested=hi bar_nested=(1 2 |
83 |
+ 3) |
84 |
+ func_nested1 |
85 |
+ } |
86 |
+ func_nested2 |