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 1QOWE4-0005Qn-24 for garchives@archives.gentoo.org; Mon, 23 May 2011 14:35:20 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C64121C059; Mon, 23 May 2011 14:34:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 85BF61C05B for ; Mon, 23 May 2011 14:34:22 +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 3BA9E1B4027 for ; Mon, 23 May 2011 14:34:22 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 9D1248050D for ; Mon, 23 May 2011 14:34:21 +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: <0b81725ba19e24f5fbbe7e0026058aa93f6a9965.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: /, utils/ X-VCS-Repository: proj/libbash X-VCS-Files: Makefile.am utils/instruo.cpp utils/isolated-functions.sh X-VCS-Directories: / utils/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 0b81725ba19e24f5fbbe7e0026058aa93f6a9965 Date: Mon, 23 May 2011 14:34:21 +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: 68c6eae4d05524dfccfc114eb268bf1d commit: 0b81725ba19e24f5fbbe7e0026058aa93f6a9965 Author: Mu Qiao gentoo org> AuthorDate: Sun May 22 09:41:22 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Mon May 23 15:04:45 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D0b81725b Utility: support misc functions for instruo "has", "hasq" and "die" are supported for instruo. --- Makefile.am | 1 + utils/instruo.cpp | 2 +- utils/isolated-functions.sh | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletions(-) diff --git a/Makefile.am b/Makefile.am index 011f011..267240e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -225,6 +225,7 @@ EXTRA_DIST =3D bashast/bashast.g \ scripts/illegal_script.sh \ scripts/foo.eclass \ utils/metadata_diff.sh \ + utils/isolated-functions.sh \ test_coverage.sh \ autogen.sh \ $(BASH_TESTS) \ diff --git a/utils/instruo.cpp b/utils/instruo.cpp index da020c3..8206b95 100644 --- a/utils/instruo.cpp +++ b/utils/instruo.cpp @@ -103,7 +103,7 @@ void worker(const std::shared_ptr = &ids) variables["PVR"][0] + ".ebuild"); try { - libbash::interpret(ebuild_path, variables, functions); + libbash::interpret(ebuild_path, "utils/isolated-functions.sh", var= iables, functions); } catch(const interpreter_exception& e) { diff --git a/utils/isolated-functions.sh b/utils/isolated-functions.sh new file mode 100755 index 0000000..efbf933 --- /dev/null +++ b/utils/isolated-functions.sh @@ -0,0 +1,22 @@ +die(){ + echo "Die is called. Something went wrong while interpreting" +} + +has() { + hasq "$@" +} + +hasq() { + for item in ${*:2} + do + [[ $item =3D=3D $1 ]] && return 0 + done + return 1 +} + +EXPORT_FUNCTIONS() { + if [ -z "$ECLASS" ]; then=20 + die "EXPORT_FUNCTIONS without a defined ECLASS" + fi =20 + $__export_funcs_var=3D"$__export_funcs_var $*"=20 +}