1 |
commit: d23dab871c34b69444bab8ef0f30ca45314600f8 |
2 |
Author: André Aparício <aparicio99 <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue May 29 18:26:04 2012 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jul 8 09:22:30 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=d23dab87 |
7 |
|
8 |
Walker: Improve command list to support "command && command && command" |
9 |
|
10 |
--- |
11 |
bashast/libbashWalker.g | 7 ++++--- |
12 |
scripts/command_execution.bash | 3 +++ |
13 |
2 files changed, 7 insertions(+), 3 deletions(-) |
14 |
|
15 |
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g |
16 |
index 9157574..0c21ccd 100644 |
17 |
--- a/bashast/libbashWalker.g |
18 |
+++ b/bashast/libbashWalker.g |
19 |
@@ -736,18 +736,19 @@ argument[std::vector<std::string>& args, bool split] |
20 |
} |
21 |
}; |
22 |
|
23 |
-logic_command_list |
24 |
+logic_command |
25 |
@declarations { |
26 |
bool logic_and; |
27 |
} |
28 |
- :command |
29 |
- |^((LOGICAND { logic_and = true; } | LOGICOR { logic_and = false; }) command { |
30 |
+ : ^((LOGICAND { logic_and = true; } | LOGICOR { logic_and = false; }) logic_command_list { |
31 |
if(logic_and ? !walker->get_status() : walker->get_status()) |
32 |
command(ctx); |
33 |
else |
34 |
seek_to_next_tree(ctx); |
35 |
}); |
36 |
|
37 |
+logic_command_list: command | logic_command; |
38 |
+ |
39 |
command_list: ^(LIST logic_command_list+); |
40 |
|
41 |
compound_command |
42 |
|
43 |
diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash |
44 |
index 58f1279..4c04908 100644 |
45 |
--- a/scripts/command_execution.bash |
46 |
+++ b/scripts/command_execution.bash |
47 |
@@ -17,6 +17,9 @@ false && echo "wrong" |
48 |
false || echo "right" |
49 |
true || |
50 |
echo "wrong" |
51 |
+echo right1 && echo right2 && false && echo wrong |
52 |
+false || echo right3 || echo wrong |
53 |
+true && false || echo right4 && echo right5 |
54 |
echo "end" |
55 |
: ${DEFAULTED:="yes"} |
56 |
FOO="abc" echo "command environment" |