aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Aparício <aparicio99@gmail.com>2012-05-29 19:26:04 +0100
committerAndré Aparício <aparicio99@gmail.com>2012-07-08 10:22:30 +0100
commitd23dab871c34b69444bab8ef0f30ca45314600f8 (patch)
tree71793d1312deb8a2450b58bacc22d98c682e1c5a
parentBuiltin: Implement unset array support (diff)
downloadlibbash-d23dab871c34b69444bab8ef0f30ca45314600f8.tar.gz
libbash-d23dab871c34b69444bab8ef0f30ca45314600f8.tar.bz2
libbash-d23dab871c34b69444bab8ef0f30ca45314600f8.zip
Walker: Improve command list to support "command && command && command"
-rw-r--r--bashast/libbashWalker.g7
-rw-r--r--scripts/command_execution.bash3
2 files changed, 7 insertions, 3 deletions
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 9157574..0c21ccd 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -736,18 +736,19 @@ argument[std::vector<std::string>& args, bool split]
}
};
-logic_command_list
+logic_command
@declarations {
bool logic_and;
}
- :command
- |^((LOGICAND { logic_and = true; } | LOGICOR { logic_and = false; }) command {
+ : ^((LOGICAND { logic_and = true; } | LOGICOR { logic_and = false; }) logic_command_list {
if(logic_and ? !walker->get_status() : walker->get_status())
command(ctx);
else
seek_to_next_tree(ctx);
});
+logic_command_list: command | logic_command;
+
command_list: ^(LIST logic_command_list+);
compound_command
diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash
index 58f1279..4c04908 100644
--- a/scripts/command_execution.bash
+++ b/scripts/command_execution.bash
@@ -17,6 +17,9 @@ false && echo "wrong"
false || echo "right"
true ||
echo "wrong"
+echo right1 && echo right2 && false && echo wrong
+false || echo right3 || echo wrong
+true && false || echo right4 && echo right5
echo "end"
: ${DEFAULTED:="yes"}
FOO="abc" echo "command environment"