Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: base-system@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH eutils] Introduce has_iuse() for IUSE checks.
Date: Tue, 13 Sep 2011 10:20:29
Message-Id: 1315909291-4205-1-git-send-email-mgorny@gentoo.org
Such checks are used at least in autotools-utils & kde* eclasses, and
are done wrong there. Thus, I've created a little reusable snippet
suitable for eutils.
---
 eclass/eutils.eclass |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index cd1f9ff..3d99f92 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -2028,3 +2028,18 @@ path_exists() {
 		-o) return $(( r == $# )) ;;
 	esac
 }
+
+# @FUNCTION: has_iuse
+# @USAGE: flag
+# @DESCRIPTION:
+# Determines whether the given flag is in IUSE. Strips IUSE default prefixes
+# as necessary.
+has_iuse() {
+	debug-print-function ${FUNCNAME} "$@"
+	[[ ${#} -eq 1 ]] || die 'Invalid args to has_iuse()'
+
+	local flag=${1}
+	local liuse=( ${IUSE} )
+
+	has "${flag}" "${liuse[@]#[+-]}"
+}
-- 
1.7.6.1

Replies

Subject Author
Re: [gentoo-dev] [PATCH eutils] Introduce has_iuse() for IUSE checks. "Michał Górny" <mgorny@g.o>
Re: [gentoo-dev] [PATCH eutils] Introduce has_iuse() for IUSE checks. Ciaran McCreesh <ciaran.mccreesh@××××××××××.com>