From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QIIIY-0001iN-5n for garchives@archives.gentoo.org; Fri, 06 May 2011 10:30:14 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D90F01C0C2; Fri, 6 May 2011 10:30:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A86F91C0C4 for ; Fri, 6 May 2011 10:30:00 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E276D1B404F for ; Fri, 6 May 2011 10:29:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 163C780505 for ; Fri, 6 May 2011 10:29:59 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/libbashWalker.g scripts/command_execution.bash scripts/command_execution.bash.result X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: ea40bc721b3926876dcde99289865c5f023ee0e2 Date: Fri, 6 May 2011 10:29:59 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 425448239213463a7747aed23a1d9254 commit: ea40bc721b3926876dcde99289865c5f023ee0e2 Author: Mu Qiao gentoo org> AuthorDate: Fri May 6 06:50:49 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Fri May 6 06:54:52 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Dea40bc72 Walker: support logical command list && and || operators are supported for command list. --- bashast/libbashWalker.g | 11 +++++++++-- scripts/command_execution.bash | 5 +++++ scripts/command_execution.bash.result | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index 203cd28..064556a 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -310,9 +310,16 @@ argument[std::vector& args] }; =20 logic_command_list +@declarations { + bool logic_and; +} :command - |^(LOGICAND command command) - |^(LOGICOR command command); + |^((LOGICAND { logic_and =3D true; } | LOGICOR { logic_and =3D false; }= ) command { + if(logic_and ? !walker->get_status() : walker->get_status()) + command(ctx); + else + seek_to_next_tree(ctx); + }); =20 command_list: ^(LIST logic_command_list+); =20 diff --git a/scripts/command_execution.bash b/scripts/command_execution.b= ash index 0f7cd03..3664356 100644 --- a/scripts/command_execution.bash +++ b/scripts/command_execution.bash @@ -8,3 +8,8 @@ true false FOO001=3D$(echo hello) FOO002=3D$(hi) +true && echo "right" +false && echo "wrong" +false || echo "right" +true || echo "wrong" +echo "end" diff --git a/scripts/command_execution.bash.result b/scripts/command_exec= ution.bash.result index 4330a65..d9f3021 100644 --- a/scripts/command_execution.bash.result +++ b/scripts/command_execution.bash.result @@ -1,4 +1,7 @@ Hello World hello world +right +right +end FOO001=3Dhello FOO002=3DHello World