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 1Sb6oq-0001El-W9 for garchives@archives.gentoo.org; Sun, 03 Jun 2012 09:09:53 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0ADEDE07B5; Sun, 3 Jun 2012 09:08:40 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id CCF9BE07B5 for ; Sun, 3 Jun 2012 09:08:40 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3BFF01B4008 for ; Sun, 3 Jun 2012 09:08:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id DA54CE5432 for ; Sun, 3 Jun 2012 09:08:37 +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: <1329967638.49facd905dadf5bae1b33362686d1d02be80a5fe.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/libbashWalker.g scripts/test_expr.bash X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 49facd905dadf5bae1b33362686d1d02be80a5fe X-VCS-Branch: master Date: Sun, 3 Jun 2012 09:08:37 +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: ca71383e-d62b-48ef-ad29-af7a9ef0db97 X-Archives-Hash: d450208929292009148bc5d87e60be1e commit: 49facd905dadf5bae1b33362686d1d02be80a5fe Author: Mu Qiao gentoo org> AuthorDate: Thu Feb 23 03:26:29 2012 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Thu Feb 23 03:27:18 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D49facd90 Walker: support shortcut in keyword test --- bashast/libbashWalker.g | 16 ++++++++++++++-- scripts/test_expr.bash | 6 ++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index bfcb73b..e357642 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -763,8 +763,20 @@ common_condition returns[bool status] |string_expr { $status =3D (!$string_expr.libbash_value.empty()); }; =20 keyword_condition returns[bool status] - :^(LOGICOR l=3Dkeyword_condition r=3Dkeyword_condition) { $status=3D l = || r; } - |^(LOGICAND l=3Dkeyword_condition r=3Dkeyword_condition) { $status=3D l= && r; } + :^(LOGICOR l=3Dkeyword_condition { + if(l){ + seek_to_next_tree(ctx); + SEEK(INDEX() + 1); + return true; + } + } r=3Dkeyword_condition) { $status=3D l || r; } + |^(LOGICAND l=3Dkeyword_condition { + if(!l){ + seek_to_next_tree(ctx); + SEEK(INDEX() + 1); + return false; + } + } r=3Dkeyword_condition) { $status=3D l && r; } |^(NEGATION l=3Dkeyword_condition) { $status =3D !l; } |^(MATCH_REGULAR_EXPRESSION left_str=3Dstring_expr right_str=3Dstring_e= xpr) { boost::xpressive::sregex re =3D boost::xpressive::sregex::compile(righ= t_str.libbash_value); diff --git a/scripts/test_expr.bash b/scripts/test_expr.bash index ccedb76..6ae7246 100644 --- a/scripts/test_expr.bash +++ b/scripts/test_expr.bash @@ -55,3 +55,9 @@ unset i [[ =3Da <=3Db ]] [[ =3Da >=3Db ]] [[ a =3D=3D a || c =3D=3D b && a =3D=3D b ]] && echo true +i=3D1 +[[ a =3D=3D b || $((i=3D0)) ]] && echo $i # i should be 0 now +[[ a =3D=3D a || $((i=3D1)) ]] && echo $i # i should still be 0 +[[ a =3D=3D b && $((i=3D1)) ]] || echo $i # i should still be 0 +i=3D1 +[[ a =3D=3D a && $((i=3D0)) ]] && echo $i # i should still be 0