From d23dab871c34b69444bab8ef0f30ca45314600f8 Mon Sep 17 00:00:00 2001 From: André Aparício Date: Tue, 29 May 2012 19:26:04 +0100 Subject: Walker: Improve command list to support "command && command && command" --- bashast/libbashWalker.g | 7 ++++--- scripts/command_execution.bash | 3 +++ 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& 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" -- cgit v1.2.3-65-gdbad